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

Connected

Exercise

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.

Instructions

100 XP
  • Import curdoc.
  • Update the theme to "contrast".
  • Add circle glyphs for north, setting x and y to represent year_built and land_area, respectively, setting color to "yellow" and legend_label to "North".
  • Repeat for south, setting color to "red" and legend_label to "South".