class: center, middle, title-slide .title[ # Principles of Figure Design ] .author[ ### Claus O. Wilke ] .date[ ### last updated: 2022-06-26 ] --- ## Topics covered -- 1. Uses of color in data visualization -- 2. Compound figures -- 3. Balance data and context --- ## Uses of color in data visualization -- <table style = "border: none; line-height: 2.5;"> <tr style = "background: white;"> <td style = "text-align: left; width: 50%;"> 1. Distinguish categories (qualitative) </td> <td> <img src = "figure-design_files/qualitative.png" width = 100% style = "text-align: right; vertical-align: middle;"></img> </td> </tr> -- <tr style = "background: white;"> <td style = "text-align: left;"> 2. Represent numeric values (sequential) </td> <td> <img src = "figure-design_files/sequential.png" width = 100% style = "text-align: right; vertical-align: middle"></img> </td> </tr> -- <tr style = "background: white;"> <td style = "text-align: left;"> 3. Represent numeric values (diverging) </td> <td> <img src = "figure-design_files/diverging.png" width = 100% style = "text-align: right; vertical-align: middle"></img> </td> </tr> -- <tr style = "background: white;"> <td style = "text-align: left;"> 4. Highlight </td> <td> <img src = "figure-design_files/highlight.png" width = 100% style = "text-align: right; vertical-align: middle"></img> </td> </tr> </table> --- ## 1. Distinguish categories (qualitative) <img src = "figure-design_files/qualitative.png" width = 100%></img> --- ## Qualitative scale example .center.nogap[ ![](figure-design_files/figure-html/popgrowth-vs-popsize-colored-1.svg)<!-- --> ] Palette name: Okabe-Ito ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Qualitative scale example .center.nogap[ ![](figure-design_files/figure-html/popgrowth-vs-popsize-colored2-1.svg)<!-- --> ] Palette name: ColorBrewer Set1 ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Qualitative scale example .center.nogap[ ![](figure-design_files/figure-html/popgrowth-vs-popsize-colored3-1.svg)<!-- --> ] Palette name: ColorBrewer Set3 ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## 2. Represent numeric values (sequential) <img src = "figure-design_files/sequential.png" width = 100%></img> --- ## Sequential scale example <br> .center[ ![](figure-design_files/figure-html/four-locations-temps-by-month-1.svg)<!-- --> ] Palette name: Viridis ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Sequential scale example <br> .center[ ![](figure-design_files/figure-html/four-locations-temps-by-month2-1.svg)<!-- --> ] Palette name: Inferno ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Sequential scale example <br> .center[ ![](figure-design_files/figure-html/four-locations-temps-by-month3-1.svg)<!-- --> ] Palette name: Cividis ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## 3. Represent numeric values (diverging) <img src = "figure-design_files/diverging.png" width = 100%></img> --- ## Diverging scale example .center.nogap[ ![](figure-design_files/figure-html/forensic-correlations1-1.svg)<!-- --> ] Palette name: ColorBrewer PiYG ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Diverging scale example .center.nogap[ ![](figure-design_files/figure-html/forensic-correlations2-1.svg)<!-- --> ] Palette name: Carto Earth ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Diverging scale example .center.nogap[ ![](figure-design_files/figure-html/forensic-correlations3-1.svg)<!-- --> ] Palette name: Blue-Red ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## 4. Highlight <img src = "figure-design_files/highlight.png" width = 100%></img> --- ## Highlight example .center[ ![](figure-design_files/figure-html/Aus-athletes-track-1.svg)<!-- --> ] Palette name: Grays with accents ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Highlight example .center[ ![](figure-design_files/figure-html/Aus-athletes-track2-1.svg)<!-- --> ] Palette name: Okabe-Ito accent ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Highlight example .center[ ![](figure-design_files/figure-html/Aus-athletes-track3-1.svg)<!-- --> ] Palette name: ColorBrewer accent ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Uses of color in data visualization <table style = "border: none; line-height: 2.5;"> <tr style = "background: white;"> <td style = "text-align: left; width: 50%;"> 1. Distinguish categories (qualitative) </td> <td> <img src = "figure-design_files/qualitative.png" width = 100% style = "text-align: right; vertical-align: middle;"></img> </td> </tr> <tr style = "background: white;"> <td style = "text-align: left;"> 2. Represent numeric values (sequential) </td> <td> <img src = "figure-design_files/sequential.png" width = 100% style = "text-align: right; vertical-align: middle"></img> </td> </tr> <tr style = "background: white;"> <td style = "text-align: left;"> 3. Represent numeric values (diverging) </td> <td> <img src = "figure-design_files/diverging.png" width = 100% style = "text-align: right; vertical-align: middle"></img> </td> </tr> <tr style = "background: white;"> <td style = "text-align: left;"> 4. Highlight </td> <td> <img src = "figure-design_files/highlight.png" width = 100% style = "text-align: right; vertical-align: middle"></img> </td> </tr> </table> --- class: center middle ## Compound figures --- ## Compound figures Two common scenarios: -- 1\. The same type of plot is replicated many times (small multiples) -- 2\. Several disparate plots are combined into one display --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/titanic-passenger-breakdown-1.png") background-position: left 50% top 60% background-size: 45% ## 1. Small multiples (facets) ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/balance_data_context_files/figure-html/titanic-survival-by-gender-class-bad-1.png") background-position: left 50% top 60% background-size: 45% ## 1. Small multiples (facets) .absolute-bottom-left[ Avoid bars or other elements that are floating in space ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/balance_data_context_files/figure-html/titanic-survival-by-gender-class-1.png") background-position: left 50% top 60% background-size: 45% ## 1. Small multiples (facets) ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- class: center middle ## Small multiples work even for massive amounts of data --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/movie-rankings-1.png") background-position: left 50% top 60% background-size: 45% ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/BA-degrees-variable-y-lims-1.png") background-position: left 50% top 70% background-size: 50% ## y-axis ranges should be consistent among panels ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/BA-degrees-fixed-y-lims-1.png") background-position: left 50% top 70% background-size: 50% ## y-axis ranges should be consistent among panels ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/BA-degrees-compound-1.png") background-position: left 50% top 55% background-size: 75% ## 2. Combining disparate figures into one display ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) -- .absolute-bottom-left[ Note: We now need plot labels (a), (b) to identify sub-plots ] --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/BA-degrees-compound-bad-1.png") background-position: left 50% top 55% background-size: 75% ## Don't use overly large or otherwise prominent labels .absolute-bottom-left[ Note: Also don't use serif fonts (such as Times) for labels ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/athletes-composite-good-1.png") background-position: left 50% top 65% background-size: 50% ## Use a consistent color language among sub-plots ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/athletes-composite-inconsistent-1.png") background-position: left 50% top 65% background-size: 50% ## Use a consistent color language among sub-plots ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/athletes-composite-good-1.png") background-position: left 50% top 65% background-size: 50% ## Pay attention to sub-plot alignment ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/athletes-composite-misaligned-1.png") background-position: left 50% top 65% background-size: 50% ## Pay attention to sub-plot alignment ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/athletes-composite-good-1.png") background-position: left 50% top 65% background-size: 50% ## Combine plots of different types .absolute-bottom-left[ This helps your readers to distinguish different parts of the analysis ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/telling_a_story_files/figure-html/athletes-composite-repetitive-1.png") background-position: left 50% top 65% background-size: 50% ## Combine plots of different types .absolute-bottom-left[ This helps your readers to distinguish different parts of the analysis ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/multi-panel_figures_files/figure-html/athletes-composite-good-1.png") background-position: left 50% top 65% background-size: 50% ## Combine plots of different types .absolute-bottom-left[ This helps your readers to distinguish different parts of the analysis ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Distinguish infographics from figures in article/book There are two distinct use cases: -- **Infographic:** Standalone, has title/subtitle/caption -- **Figure in article/book:** Caption contains title, not part of figure --- background-image: url("https://clauswilke.com/dataviz/figure_titles_captions_files/figure-html/corruption-development-infographic-1.png") background-position: left 50% top 45% background-size: 50% .absolute-bottom-left[ Example of infographic ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/figure_titles_captions_files/figure-html/corruption-development-1.png") background-position: left 15% top 40% background-size: 50% .pull-right.width-35.move-down-2em.small-font[ Figure 1. **Corruption and human development.** The most developed countries experience the least corruption. Inspired by a posting in [The Economist online (2011)](https://www.economist.com/graphic-detail/2011/12/02/corrosive-corruption). Data sources: Transparency International & UN Human Development Report. ] .absolute-bottom-left[ Example of figure in article or book ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- class: center middle ## Balance data and context --- background-image: url("https://clauswilke.com/dataviz/figure_titles_captions_files/figure-html/blue-jays-scatter-bubbles2-1.png") background-position: left 50% top 60% background-size: 45% ## Label all axes and guides .absolute-bottom-left[ Add units where appropriate or necessary ] --- background-image: url("https://clauswilke.com/dataviz/figure_titles_captions_files/figure-html/tech-stocks-minimal-labeling-1.png") background-position: left 50% top 60% background-size: 55% ## Self-explanatory labels can be omitted --- background-image: url("https://clauswilke.com/dataviz/balance_data_context_files/figure-html/Aus-athletes-grid-bad-1.png") background-position: left 50% top 60% background-size: 55% ## Don't overload your figure with boxes and grid-lines --- background-image: url("https://clauswilke.com/dataviz/balance_data_context_files/figure-html/Aus-athletes-min-bad-1.png") background-position: left 50% top 60% background-size: 55% ## But also don't hide useful information --- background-image: url("https://clauswilke.com/dataviz/balance_data_context_files/figure-html/Aus-athletes-grid-good-1.png") background-position: left 50% top 60% background-size: 55% ## Axes and grid should be visible but not dominate --- background-image: url("https://clauswilke.com/dataviz/balance_data_context_files/figure-html/Aus-athletes-grid-good-frame-1.png") background-position: left 50% top 60% background-size: 55% ## A box around the figure can help separate the legend --- ## Further reading Relevant chapters from Fundamentals of Data Visualization: - [Chapter 4: Color scales](https://clauswilke.com/dataviz/color-basics.html) - [Chapter 21: Multi-panel figures](https://clauswilke.com/dataviz/multi-panel-figures.html) - [Chapter 22: Titles, captions, and tables](https://clauswilke.com/dataviz/figure-titles-captions.html) - [Chapter 23: Balance the data and the context](https://clauswilke.com/dataviz/balance-data-context.html)