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

Exercise

Improving your KDEs

One way of enhancing KDEs is with the addition of a rug plot. Rug plots are little dashes drawn beneath the density that show precisely where each data point falls. Adding a rug plot is particularly useful when you don't have a ton of data.

With small amounts of data you often have gaps along your support with no data, and it can be hard to tell whether a non-zero KDE line means data was present or is due to a wide kernel. A rug plot helps address this.

Let's return to the sns.distplot() function to draw two KDEs: one looking at the data for Vandenberg Air Force Base and the other looking at all the other cities in the pollution data. Since there is much less data contributing to the shape of the Vandenberg plot, add a rug plot beneath it.

Instructions

100 XP
  • Turn off the histogram overlay for the first plot.
  • Make the Vandenberg plot 'steelblue'.
  • Turn on rug plot functionality in the Vandenberg plot.
  • Remove histogram from the non-Vandenberg plot and set its color to 'gray'.