Customizing glyphs
The estate agents have requested a plot displaying the relationship between the year a property was built and its distance to the Central Business District (CBD), distinguishing between houses, units, and townhouses. You decide to use different colors and glyphs for each of the three property types.
Three subsets of melb have been created and preloaded for you:
houses = melb.loc[melb["type"] == "h"]
units = melb.loc[melb["type"] == "u"]
townhouses = melb.loc[melb["type"] == "t"]
Este exercicio faz parte do curso
Interactive Data Visualization with Bokeh
Instruções do exercicio
- Create a figure,
fig, setting x and y-axes labels to"Year Built"and"Distance from CBD (km)", respectively. - Add purple circle glyphs to represent
houses, plotting"year_built"on the x-axis and"distance"on the y-axis, and labeling the legend as"House". - Repeat the above, this time using red square glyphs for
units, with the legend labeled as"Unit". - Repeat once more using green triangle glyphs to represent
townhousesand setting the legend label to"Townhouse".
exercicio interativo prático
Tente este exercicio completando este código de exemplo.
# Create figure
fig = ____
# Add circle glyphs for houses
fig.____(x=houses["____"], y=houses["____"], legend_label="____", color="____")
# Add square glyphs for units
fig.____(____=____, ____=____, ____="____", ____="____")
# Add triangle glyphs for townhouses
____
output_file(filename="year_built_vs_distance_by_property_type.html")
show(fig)