1. Learn
  2. /
  3. Courses
  4. /
  5. Improving Your Data Visualizations in Python

Exercise

Using a plot as a legend

One interesting thread of investigation in the farmer's market data is a state's "market friendliness" and specifically, the outliers. One way to look at this is by using the ratio of farmer's markets to people by state. You could directly look at the ratio; however, a ratio throws away the raw information about a state's population and the number of markets. A large state with a high ratio could be more interesting than a small one.

You can show both the ratio and raw numbers by drawing two plots, one of the ratio and the other of the market number to population scatter plot. To help simplify your now dense visualization, you can use the bar plot as a legend; calling out interesting states by matching the colors of their bars and scatter points.

Instructions

100 XP
  • Set up two plots side-by-side using plt.subplots().
  • Map the column is_selected to the color of both the bar and scatter plot.
  • Disable dodge on the bar plot, so the bars are full height.
  • Remove the legends in both plots.