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!
This exercise is part of the course
Interactive Data Visualization with Bokeh
Exercise instructions
- Import
gridplot
. - Create
df
by filteringmelb
for the desired region. - Complete the code to add circle glyphs to
fig
, representingx
as the building area column andy
as price, fromsource
, andlegend_label
asregion
. - Display the subplots in a grid using two columns.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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=____))