Exercise 3.5: Automating scatter plots


You may notice that we often have to retype things like,

p = bokeh.plotting.figure(
    frame_width=300,
    frame_height=250,
    x_axis_label='x',
    y_axis_label='y',
)

and the like when making plots. You may have a certain kind of plot you often make in your work, so you might want make functions to quickly generate the kinds of plots you want. Scatter plots come up very often. Write a function that takes as input a tidy data frame and generates a scatter plot based on two columns of the data frame and colors the glyphs according to a third column that contains categorical variables. The minimal (you can add other kwargs if you want) call signature should be

scatter(data, x, y, cat)

You will of course test out your function while writing it, and the next exercises give you lots of opportunities to use it.