Visualizing sales by period
Now you have created your factors, it is time to build a bar plot visualizing sales per month, grouped into quarters!
grouped_melb, a pandas DataFrame containing one row for each month, its respective quarter, and total sales for that month, has been preloaded for you. Additionally, factors, which is a list of tuples containing each quarter and month pair, has also been preloaded.
Este exercício faz parte do curso
Interactive Data Visualization with Bokeh
Instruções do exercício
- Import
NumeralTickFormatterandFactorRange. - Create the figure, using
FactorRange()andfactorsfor the x-axis, and labeling the y-axis as"Sales". - Add bar glyphs, setting
xasfactors,topas the"price"column ofgrouped_melb, andwidthas0.9. - Rotate the x-axis labels to 45 degrees.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Import NumeralTickFormatter and FactorRange
from ____.____ import ____, ____
# Create figure
fig = ____(x_range=____(____), ____="____")
# Create bar glyphs
____
fig.yaxis[0].formatter = NumeralTickFormatter(format="$0.0a")
# Rotate the x-axis labels
fig.____.____ = ____
output_file(filename="sales_by_period.html")
show(fig)