Colors, legend, and theme
For your first assignment, the estate agents would like a visualization to represent the relationship between the year a property was built and its total land area, factoring in how this varies between the Northern and Southern regions of Melbourne. You decide to use one of Bokeh's custom themes for the plot.
Two subsets of melb
have been created based on which region
a property is located in, north
and south
, as shown below:
north = melb.loc[melb["region"] == "Northern"]
south = melb.loc[melb["region"] == "Southern"]
A figure, fig
, has been preloaded for you. You will update the theme, and add circle glyphs using different colors for each region. You will then add a legend_label
so they can be easily distinguished.
This exercise is part of the course
Interactive Data Visualization with Bokeh
Exercise instructions
- Import
curdoc
. - Update the theme to
"contrast"
. - Add circle glyphs for
north
, settingx
andy
to representyear_built
andland_area
, respectively, settingcolor
to"yellow"
andlegend_label
to"North"
. - Repeat for
south
, settingcolor
to"red"
andlegend_label
to"South"
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import curdoc
from ____.____ import ____
# Change theme to contrast
____().____ = "____"
fig = figure(x_axis_label="Year Built", y_axis_label="Land Area (Meters Squared)")
# Add north circle glyphs
fig.circle(x=north["____"], y=north["____"], color="____", legend_label="____")
# Add south circle glyphs
fig.____(____=____, ____=____, ____="____", legend_label="____")
output_file(filename="north_vs_south.html")
show(fig)