Get startedGet started for free

Sales by time and type of day

The bakery you are working with is considering a review of their opening hours. As such, they have asked you to produce a visualization displaying sales information by the time of day for weekdays and weekends.

The day_time column of bakery contains four values: "Morning", "Afternoon", "Evening", and "Night".

The dataset also contains "Weekend" and "Weekday" values for the day_type column.

You will produce a grouped bar plot visualizing sales by both time and type of day. FactorRange has been imported for you.

The bakery dataset has been grouped by day_time and day_type, stored as grouped_bakery, and preloaded for you. A tuple containing every variation of these two columns has been stored as factors and also preloaded for you.

This exercise is part of the course

Interactive Data Visualization with Bokeh

View Course

Exercise instructions

  • Create fig, setting the x_range by calling FactorRange() and passing *factors, assigning "Sales" to the y-axis label, and giving a title of "Sales by type of day".
  • Add bar glyphs for factors, with the top represented by grouped_bakery["sales"], and bar width to 90%.
  • Update the title font size to "25px".
  • Change the format of the title to center alignment.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create figure
fig = ____

# Create bar glyphs
____
fig.yaxis[0].formatter = NumeralTickFormatter(format="$0,0")

# Update title text size
fig.____.____ = "____"

# Update title alignment
fig.____.____ = "____"

output_file("sales_by_type_of_day.html")
show(fig)
Edit and Run Code