LoslegenKostenlos loslegen

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

Diese Übung ist Teil des Kurses

Interactive Data Visualization with Bokeh

Kurs anzeigen

Anleitung zur Übung

  • 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".

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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)
Code bearbeiten und ausführen