Skip to content

Commit

Permalink
Fix subfigs
Browse files Browse the repository at this point in the history
  • Loading branch information
mine-cetinkaya-rundel committed Sep 11, 2023
1 parent 0093279 commit 3cc66d6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
26 changes: 14 additions & 12 deletions 06-explore-applications.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ When creating a graphic, keep in mind what it is that you'd like your reader to
Colors should be used to group items or differentiate levels in meaningful ways.
Colors can be distracting when they are only used to brighten up the plot.

Consider a manufacturing company that has summarized their costs into five different categories.
In the two graphics provided in Figure @fig-pie-to-bar, notice that the magnitudes in the pie chart are difficult for the eye to compare.
Consider a manufacturing company that has summarized its costs into five different categories.
In the two graphics provided in @fig-pie-to-bar, notice that the magnitudes in the pie chart in @fig-pie-to-bar-1 are difficult for the eye to compare.
That is, can your eye tell how different "Buildings and administration" is from "Workplace materials" when looking at the slices of pie?
Additionally, the colors in the pie chart do not mean anything and are therefore distracting.
Lastly, the three-dimensional aspect of the image does not improve the reader's ability to understand the data presented.

As an alternative, a bar plot has been provided.
Notice how much easier it is to identify the magnitude of the differences across categories while not being distracted by other aspects of the image.
As an alternative, a bar plot is been provided in @fig-pie-to-bar-2. Notice how much easier it is to identify the magnitude of the differences across categories while not being distracted by other aspects of the image.
Typically, a bar plot will be easier for the reader to digest than a pie chart, especially if the categorical data being plotted has more than just a few levels.

```{r}
Expand All @@ -46,7 +45,10 @@ expenses <- tribble(

```{r}
#| label: fig-pie-to-bar
#| fig-cap: A pie chart (with added irrelevant features) as compared to a simple bar plot.
#| fig-cap: Same information displayed with two very different visualizations.
#| fig-subcap:
#| - A three-dimensional pie chart.
#| - A bar plot.
#| layout-ncol: 2
#| out.width: 50%
Expand All @@ -64,7 +66,7 @@ There are many reasons why you might choose to add **color** to your plots.
An important principle to keep in mind is to use color to draw attention.
Of course, you should still think about how visually pleasing your visualization is, and if you're adding color for making it visually pleasing without drawing attention to a particular feature, that might be fine.
However, you should be critical of default coloring and explicitly decide whether to include color and how.
Notice that in Plot B in Figure @fig-red-bar the coloring is done in such a way to draw the reader's attention to one particular piece of information.
Notice that in Plot B in @fig-red-bar the coloring is done in such a way to draw the reader's attention to one particular piece of information.
The default coloring in Plot A can be distracting and makes the reader question, for example, is there something similar about the red and purple bars?
Also note that not everyone sees color the same way, often it's useful to add color and one more feature (e.g., pattern) so that you can refer to the features you're drawing attention to in multiple ways.

Expand Down Expand Up @@ -108,7 +110,7 @@ terms_chp_6 <- c("color in plots")

For many graphs, an important aspect is the inclusion of information which is not provided in the dataset that is being plotted.
The external information serves to contextualize the data and helps communicate the narrative of the research.
In Figure @fig-duke-hires, the graph on the right is **annotated** with information about the start of the university's fiscal year which contextualizes the information provided by the data.
In @fig-duke-hires, the graph on the right is **annotated** with information about the start of the university's fiscal year which contextualizes the information provided by the data.
Sometimes the additional information may be a diagonal line given by $y = x$, points above the line quickly show the reader which values have a $y$ coordinate larger than the $x$ coordinate; points below the line show the opposite.

```{r}
Expand All @@ -127,7 +129,7 @@ knitr::include_graphics("images/time-series-story.png")

Most software programs have built in methods for some of the plot details.
For example, the default option for the software program used in this text, R, is to order the bars in a bar plot alphabetically.
As seen in Figure @fig-brexit-bars, the alphabetical ordering isn't particularly meaningful for describing the data.
As seen in @fig-brexit-bars, the alphabetical ordering isn't particularly meaningful for describing the data.
Sometimes it makes sense to **order** the bars from tallest to shortest (or vice versa).
But in this case, the best ordering is probably the one in which the questions were asked.
An ordering which does not make sense in the context of the problem (e.g., alphabetically here), can mislead the reader who might take a quick glance at the axes and not read the bar labels carefully.
Expand Down Expand Up @@ -193,7 +195,7 @@ p_bad + p_desc + p_ordered + plot_spacer() +

The Brexit survey results were additionally broken down by region in Great Britain.
The stacked bar plot allows for comparison of Brexit opinion across the five regions.
In Figure @fig-brexit-region the bars are vertical in Plot A and horizontal in Plot B. While the quantitative information in the two graphics is identical, flipping the graph and creating horizontal bars provides more space for the **axis labels**.
In @fig-brexit-region the bars are vertical in Plot A and horizontal in Plot B. While the quantitative information in the two graphics is identical, flipping the graph and creating horizontal bars provides more space for the **axis labels**.
The easier the categories are to read, the more the reader will learn from the visualization.
Remember, the goal is to convey as much information as possible in a succinct and clear manner.

Expand Down Expand Up @@ -247,15 +249,15 @@ Every graphical decision should be made with a **purpose**.
As previously mentioned, sticking with default options is not always best for conveying the narrative of your data story.
Stacked bar plots tell one part of a story.
Depending on your research question, they may not tell the part of the story most important to the research.
Figure @fig-seg-three-ways provides three different ways of representing the same information.
@fig-seg-three-ways provides three different ways of representing the same information.
If the most important comparison across regions is proportion, you might prefer Plot A. If the most important comparison across regions also considers the total number of individuals in the region, you might prefer Plot B. If a separate bar plot for each region makes the point you'd like, use Plot C, which has been **faceted** by region.

```{r}
#| include: false
terms_chp_6 <- c(terms_chp_6, "faceting graphics")
```

Plot C in Figure @fig-seg-three-ways also provides full titles and a succinct URL with the data source.
Plot C in @fig-seg-three-ways also provides full titles and a succinct URL with the data source.
Other deliberate decisions to consider include using informative labels and avoiding redundancy.

```{r}
Expand Down Expand Up @@ -308,7 +310,7 @@ One last consideration for building graphs is to consider color choices.
Default or rainbow colors are not always the choice which will best distinguish the level of your variables.
Much research has been done to find color combinations which are distinct and which are clear for differently sighted individuals.
The cividis scale works well with ordinal data.
[@Nunez:2018] Figure @fig-brexit-viridis shows the same plot with two different colorings.
[@Nunez:2018] @fig-brexit-viridis shows the same plot with two different color themes.

```{r}
#| label: fig-brexit-viridis
Expand Down
Loading

0 comments on commit 3cc66d6

Please sign in to comment.