Annual ticket bars for three venues, with comma values and hatching

Write code · Medium · §10.4 Assembling an HTML report

The table tickets holds the quarterly ticket sales at three venues, Arts, Civic, and River, in 2026. Draw each venue's annual total, the sum of four quarters, as one bar. Put the venue (hall) on the x-axis and the total (tickets) on the y-axis, and split the bar colors by venue as hall_colors says.

So that the bars stay distinct when printed in black and white, also split the hatching by venue: no hatching for Arts, / for Civic, and x for River. Write each total at the end of its bar with thousands separators, as in 12,100, and use the title Tickets sold in 2026. Show the figure with fig.show(). Grading changes the ticket sales and the color dictionary and draws the chart again.

Target figure for Annual ticket bars for three venues, with comma values and hatching
Target figure

Starter code

import pandas as pd
import plotly.express as px

tickets = pd.DataFrame({
    "quarter": ["Q1", "Q2", "Q3", "Q4"] * 3,
    "hall": ["Arts"] * 4 + ["Civic"] * 4 + ["River"] * 4,
    "tickets": [2450, 3120, 2890, 3640, 1980, 2210, 2570, 2930, 1320, 1875, 2405, 1760],
})
hall_colors = {"Arts": "#CC79A7", "Civic": "#009E73", "River": "#56B4E9"}

# Write your code here

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.