color in v is u ali z ations
play

Color in v is u ali z ations IMP R OVIN G YOU R DATA VISU AL - PowerPoint PPT Presentation

Color in v is u ali z ations IMP R OVIN G YOU R DATA VISU AL IZATION S IN P YTH ON Nick Stra y er Instr u ctor Ho w color is u sed Di erentiates classes of data Encodes contin u o u s v al u es Sho u ld be u sed caref u ll y IMPROVING YOUR


  1. Color in v is u ali z ations IMP R OVIN G YOU R DATA VISU AL IZATION S IN P YTH ON Nick Stra y er Instr u ctor

  2. Ho w color is u sed Di � erentiates classes of data Encodes contin u o u s v al u es Sho u ld be u sed caref u ll y IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  3. Color can be bea u tif u l Boring → e y e - catching Variet y is good IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  4. Meaning is o � en applied to colors v ia c u lt u re / personal e x perience 1 Parlapiano , A . (2016 No v ember 1) There are man y w a y s to map election res u lts . We 'v e tried most of them . Ne w York Times . Retrie v ed from h � ps ://www. n y times . com / IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  5. IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  6. Color can be misleading ... " It is e v ident that the color - si z e ill u sion is present in a marked degree [ no ma � er w hat ] arrangement ." C . J . Warden & E . L . Fl y nn , 1926 IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  7. A remed y for the color - si z e ill u sion sns.barplot(x = values, y = ids) sns.barplot(x = values, y = ids, edgecolor = 'black') IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  8. sns.barplot(x = values, y = ids, color = 'cadetblue') IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  9. Let ' s paint some data ! IMP R OVIN G YOU R DATA VISU AL IZATION S IN P YTH ON

  10. Contin u o u s color palettes IMP R OVIN G YOU R DATA VISU AL IZATION S IN P YTH ON Nick Stra y er Instr u ctor

  11. IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  12. blue_scale = sns.light_palette("steelblue") sns.palplot(blue_scale) red_scale = sns.dark_palette("orangered") sns.palplot(red_scale) IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  13. IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  14. 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) IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  15. 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) IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  16. Be a w are of color blindness A v oid transitions bet w een green and red Pale � es that u se intensit y are safer IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  17. Encoding ne u tral v al u es pal_light = sns.diverging_palette(250, 0) pal_dark = sns.diverging_palette(250, 0, center = 'dark') IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  18. 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) IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  19. 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) IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  20. Let ' s contin u e in the e x ercises IMP R OVIN G YOU R DATA VISU AL IZATION S IN P YTH ON

  21. Categorical palettes IMP R OVIN G YOU R DATA VISU AL IZATION S IN P YTH ON Nick Stra y er Instr u ctor

  22. IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  23. Limits in perception Tr y and limit to 10 or fe w er categories Keep color - blindness in mind sns.palplot(sns.color_palette('Set2', 11)) IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  24. # Assign a new column to dataframe the desired combos pollution['interesting cities'] = [x if x in ['Long Beach', 'Cincinnati'] else 'other' for x in pollution['city'] ] sns.scatterplot(x="NO2", y="SO2", hue = 'interesting cities', palette='Set2', data=pollution.query('year == 2014 & month == 12')) IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  25. colorbrewer_palettes = ['Set1', 'Set2', 'Set3', 'Accent', 'Paired', 'Pastel1', 'Pastel2', 'Dark2'] for pal in colorbrewer_palettes: sns.palplot(pal=sns.color_palette(pal)) plt.title(pal, loc = 'left') IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  26. Ordinal data ( a ) Has order bet w een classes A set n u mber of distinct classes IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  27. Ordinal data ( b ) Has order bet w een classes A set n u mber of distinct classes IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  28. Ordinal data ( c ) Has order bet w een classes A set n u mber of distinct classes IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  29. colorbrewer_palettes = ['Reds', 'Blues', 'YlOrBr', 'PuBuGn', 'GnBu', 'Greys'] for i, pal in enumerate(colorbrewer_palettes): sns.palplot(pal=sns.color_palette(pal, n_colors=i+4)) IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  30. # Make a tertials column using qcut() pollution['NO2 Tertial'] = pd.qcut(pollution['NO2'], 3, labels = False) # Plot colored by the computer tertials sns.scatterplot(x="CO", y="SO2", hue='NO2 Tertial', palette="OrRd", data=pollution.query("city == 'Long Beach' & year == 2014")) IMPROVING YOUR DATA VISUALIZATIONS IN PYTHON

  31. Let ' s color some categories IMP R OVIN G YOU R DATA VISU AL IZATION S IN P YTH ON

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend