Sales over time
The estate agents have now asked you to examine house market activity to visualize changes in total sales over time. The melb
DataFrame has been grouped on date
, this time calculating total sales using the sum of the price
column, and stored as melb_sales
:
melb_sales = melb.groupby("date", as_index=False)["price"].sum()
source
has been created from melb_sales
, and preloaded for you. Your task is to format a plot to display the visualization with meaningful axes allowing for insights to be drawn.
This exercise is part of the course
Interactive Data Visualization with Bokeh
Exercise instructions
- Import the classes required to change the axis labels to
datetime
andnumeric
format. - Add line glyphs to the figure, assigning y as
"price"
versus x as"date"
fromsource
. - Update the format of the x-axis to months as three characters, and years as 4 digits.
- Set the y-axis format as
"$0a"
to display in millions of dollars.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import the second formatter
from bokeh.models import ____, ____
fig = figure(x_axis_label="Date", y_axis_label="Sales")
# Add line glyphs
fig.line(____)
# Format the x-axis format
fig.____[____].____ = ____(months="____")
# Format the y-axis format
fig.____[____].____ = ____(format="____")
output_file(filename="melbourne_sales.html")
show(fig)