Continuous color palettes

Improving Your Data Visualizations in Python

Nick Strayer

Instructor

list of continuous data types on left, non-continuous on the right

Improving Your Data Visualizations in Python
blue_scale = sns.light_palette("steelblue")
sns.palplot(blue_scale)

white to blue color palette

red_scale = sns.dark_palette("orangered")
sns.palplot(red_scale)

black to red palette

Improving Your Data Visualizations in Python

color encoded heatmap on left and bar chart on right

Improving Your Data Visualizations in Python

Keep it simple

indy_oct = pollution.query("year == 2015 & city == 'Indianapolis'")
blue_scale = sns.light_palette("steelblue", as_cmap = True)
sns.heatmap(indy_oct[['O3']], cmap = blue_scale)

light blue heatmap of o3 levels over time

Improving Your Data Visualizations in Python

Keep it simple

indy_oct = pollution.query("year == 2015 & city == 'Indianapolis'")
jet_scale = palette = sns.color_palette('jet', as_cmap = True)
sns.heatmap(indy_oct[['O3']], cmap = jet_scale)

heatmap of o3 pollution values with the colorful jet palette

Improving Your Data Visualizations in Python

Be aware of color blindness

  • Avoid transitions between green and red
  • Palettes that use intensity are safer

green to red equals sad face, light red to red equals happy face

Improving Your Data Visualizations in Python

Encoding neutral values

pal_light = sns.diverging_palette(250, 0)
pal_dark  = sns.diverging_palette(250, 0, center = 'dark')

blue to red diverging palette

heatmap of SO2 deviations encoded with blue to red diverging palette

Improving Your Data Visualizations in Python
plt.style.use('seaborn-white')

light_palette = sns.light_palette("orangered")
sns.scatterplot(x = 'CO', y = 'NO2', hue = 'O3', data = lb_2012, 
                palette = light_palette)

chart with white background and orange dots highlighting low values as lighter dots

Improving Your Data Visualizations in Python
plt.style.use('dark_background')

dark_palette = sns.dark_palette("orangered")
sns.scatterplot(x = 'CO', y = 'NO2', hue = 'O3', data = lb_2012, 
                palette = dark_palette)

chart with black background and orange dots highlighting low values as darker dots

Improving Your Data Visualizations in Python

Let's continue in the exercises

Improving Your Data Visualizations in Python

Preparing Video For Download...