Aan de slagGa gratis aan de slag

Using gridplot

The estate agents would like to examine how the relationship between property size and price varies across the four regions of Melbourne:

"Northern", "Western", "Eastern", and "Southern".

This is a great opportunity to use gridplot, displaying one subplot for each region!

Deze oefening maakt deel uit van de cursus

Interactive Data Visualization with Bokeh

Cursus bekijken

Oefeninstructies

  • Import gridplot.
  • Create df by filtering melb for the desired region.
  • Complete the code to add circle glyphs to fig, representing x as the building area column and y as price, from source, and legend_label as region.
  • Display the subplots in a grid using two columns.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import gridplot
from ____.____ import ____
plots = []

# Complete for loop to create plots
for region in ["Northern", "Western", "Southern", "Eastern"]:
  df = melb.loc[melb["region"] == ____]
  source = ColumnDataSource(data=df)
  fig = figure(x_axis_label="Building Area (Meters Squared)", y_axis_label="Price")
  fig.circle(x="____", y="____", source=____, legend_label=____)
  fig.yaxis[0].formatter = NumeralTickFormatter(format="$0a")
  plots.append(fig)

# Display plot
output_file(filename="gridplot.html")
show(____(____, ncols=____))
Code bewerken en uitvoeren