1. Learn
  2. /
  3. Courses
  4. /
  5. Interactive Data Visualization with Bokeh

Exercise

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"]

Instructions

100 XP
  • 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 townhouses and setting the legend label to "Townhouse".