Skip to content

Commit

Permalink
fix theme
Browse files Browse the repository at this point in the history
  • Loading branch information
clauswilke committed Jan 14, 2019
1 parent 95bc589 commit 9c080cd
Show file tree
Hide file tree
Showing 122 changed files with 84 additions and 57 deletions.
22 changes: 13 additions & 9 deletions aesthetic_mapping.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,20 @@ p_mtcars <- ggplot(mtcars, aes(disp, mpg, fill = hp, shape = factor(cyl), size =
scale_fill_continuous_sequential(palette = "Emrld", name = "power (hp)", breaks = c(100, 200, 300)) +
xlab("displacement (cu. in.)") +
ylab("fuel efficiency (mpg)") +
guides(shape = guide_legend(override.aes = list(size = 4, fill = "#329D84")),
size = guide_legend(override.aes = list(shape = 21, fill = "#329D84"),
title = "weight (1000 lbs)")) +
guides(
shape = guide_legend(override.aes = list(size = 4, fill = "#329D84")),
size = guide_legend(override.aes = list(shape = 21, fill = "#329D84"),
title = "weight (1000 lbs)")
) +
theme_dviz_open() + background_grid() +
theme(#legend.title = element_text(size = 12),
legend.box.background = element_rect(fill = "white", color = "white"),
legend.position = "top",
legend.direction = "vertical",
legend.justification = "center",
legend.box.margin = margin(7, 7, 7, 7))
theme(
#legend.title = element_text(size = 12),
legend.box.background = element_rect(fill = "white", color = "white"),
legend.position = "top",
legend.direction = "vertical",
legend.justification = "center",
legend.box.margin = margin(7, 7, 7, 7)
)
legend <- get_legend(align_legend(p_mtcars))
Expand Down
26 changes: 15 additions & 11 deletions avoid_line_drawings.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ h3_bad <- ggplot(age_hist_3, aes(x = age, y = count)) + geom_col(width = 2., fil
scale_x_continuous(limits = c(0, 75), expand = c(0, 0)) +
theme_dviz_open() +
background_grid(major = "y", minor = "none") +
theme(plot.margin = margin(3, 7, 3, 0))
theme(plot.margin = margin(3, 7, 3, 1.5))
stamp_bad(h3_bad)
```
Expand All @@ -41,7 +41,7 @@ h3_good <- ggplot(age_hist_3, aes(x = age, y = count)) + geom_col(width = 2.7, f
scale_x_continuous(limits = c(0, 75), expand = c(0, 0)) +
theme_dviz_open() +
background_grid(major = "y", minor = "none") +
theme(plot.margin = margin(3, 7, 3, 0))
theme(plot.margin = margin(3, 7, 3, 1.5))
h3_good
```
Expand Down Expand Up @@ -88,7 +88,7 @@ iris_lines <- ggplot(iris_dens, aes(x = Sepal.Length, y = density, linetype = Sp
scale_x_continuous(expand = c(0, 0), name = "sepal length") +
scale_y_continuous(limits = c(0, 1.5), expand = c(0, 0)) +
theme_dviz_open() +
theme(plot.margin = margin(14, 7, 3, 0))
theme(plot.margin = margin(14, 7, 3, 1.5))
stamp_ugly(iris_lines)
```
Expand Down Expand Up @@ -120,7 +120,7 @@ iris_colored_lines <- ggplot(iris_dens, aes(x = Sepal.Length, y = density, color
scale_x_continuous(expand = c(0, 0), name = "sepal length") +
scale_y_continuous(limits = c(0, 1.5), expand = c(0, 0)) +
theme_dviz_open() +
theme(plot.margin = margin(14, 7, 3, 0))
theme(plot.margin = margin(14, 7, 3, 1.5))
stamp_ugly(iris_colored_lines)
```
Expand Down Expand Up @@ -156,7 +156,7 @@ iris_filled <- ggplot(iris_dens, aes(x = Sepal.Length, y = density, fill = Speci
scale_x_continuous(expand = c(0, 0), name = "sepal length") +
scale_y_continuous(limits = c(0, 1.5), expand = c(0, 0)) +
theme_dviz_open() +
theme(plot.margin = margin(14, 7, 3, 0))
theme(plot.margin = margin(14, 7, 3, 1.5))
iris_filled
```
Expand Down Expand Up @@ -186,7 +186,7 @@ mpg_linespoints <- ggplot(mpg, aes(y=cty, x=displ, shape=drv)) +
theme_dviz_open() +
theme(
legend.position = c(.7, .8),
plot.margin = margin(3, 7, 3, 0)
plot.margin = margin(3, 7, 3, 1.5)
)
stamp_ugly(mpg_linespoints)
Expand Down Expand Up @@ -228,7 +228,7 @@ mpg_filledpoints <- ggplot(mpg, aes(y = cty, x = displ, color = drv, fill = drv,
theme_dviz_open() +
theme(
legend.position = c(.7, .8),
plot.margin = margin(3, 7, 3, 0)
plot.margin = margin(3, 7, 3, 1.5)
)
mpg_filledpoints
Expand Down Expand Up @@ -262,9 +262,11 @@ lincoln_weather %>%
mutate(month_short = fct_rev(month_short)) -> lincoln_df
lincoln_box_empty <- ggplot(lincoln_df, aes(x = month_short, y = `Mean Temperature [F]`)) +
geom_boxplot() + xlab("Month") +
geom_boxplot() +
xlab("Month") +
ylab("mean temperature (°F)") +
theme_dviz_open() +
theme(plot.margin = margin(3, 7, 3, 0))
theme(plot.margin = margin(3, 7, 3, 1.5))
lincoln_box_empty
```
Expand All @@ -274,9 +276,11 @@ lincoln_box_empty

```{r lincoln-weather-box-filled, fig.cap='(ref:lincoln-weather-box-filled)'}
lincoln_box_filled <- ggplot(lincoln_df, aes(x = month_short, y = `Mean Temperature [F]`)) +
geom_boxplot(fill = 'grey90') + xlab("Month") +
geom_boxplot(fill = 'grey90') +
xlab("Month") +
ylab("mean temperature (°F)") +
theme_dviz_open() +
theme(plot.margin = margin(3, 7, 3, 0))
theme(plot.margin = margin(3, 7, 3, 1.5))
lincoln_box_filled
```
Binary file modified docs/aesthetic_mapping_files/figure-html/mtcars-five-scale-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/avoid_line_drawings_files/figure-html/mpg-filledpoints-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/avoid_line_drawings_files/figure-html/mpg-linespoints-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/balance_data_context_files/figure-html/price-increase-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/color_basics_files/figure-html/Aus-athletes-track-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/color_basics_files/figure-html/popgrowth-US-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/color_basics_files/figure-html/popgrowth-US-highlight-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/geospatial_data_files/figure-html/sfbay-layers-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/geospatial_data_files/figure-html/sfbay-overview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/geospatial_data_files/figure-html/shiloh-map-1.png
Binary file modified docs/geospatial_data_files/figure-html/usa-true-albers-1.png
Binary file modified docs/geospatial_data_files/figure-html/world-goode-1.png
Binary file modified docs/multi-panel_figures_files/figure-html/movie-rankings-1.png
Binary file modified docs/nested_proportions_files/figure-html/bridges-mosaic-1.png
Binary file modified docs/no_3d_files/figure-html/VA-death-rates-Trellis-1.png
Binary file modified docs/no_3d_files/figure-html/mtcars-2d-multiple-1.png
Binary file modified docs/no_3d_files/figure-html/mtcars-2d-size-1.png
Binary file modified docs/overlapping_points_files/figure-html/blue-jays-contour-1.png
Binary file modified docs/telling_a_story_files/figure-html/number-of-flights-nyc-1.png
Binary file modified docs/telling_a_story_files/figure-html/petownership-bar-1.png
Binary file modified docs/telling_a_story_files/figure-html/q-bio-monthly-growth-1.png
Binary file modified docs/telling_a_story_files/figure-html/tech-stocks-diverse-1.png
Binary file modified docs/telling_a_story_files/figure-html/tech-stocks-repetitive-1.png
Binary file modified docs/time_series_files/figure-html/oats-yield-1.png
Binary file modified docs/visualizing_amounts_files/figure-html/internet-over-time-1.png
Binary file modified docs/visualizing_associations_files/figure-html/blue-jays-PCA-1.png
Binary file modified docs/visualizing_associations_files/figure-html/forensic-PCA-1.png
Binary file modified docs/visualizing_trends_files/figure-html/hpi-detrended-1.png
Binary file modified docs/visualizing_trends_files/figure-html/hpi-trends-1.png
Binary file modified docs/visualizing_trends_files/figure-html/keeling-curve-1.png
Binary file modified docs/visualizing_trends_files/figure-html/tank-capacity-loess-1.png
Binary file modified docs/visualizing_trends_files/figure-html/tank-capacity-model-1.png
Binary file modified docs/visualizing_uncertainty_files/figure-html/bayes-vs-ols-1.png
Binary file modified docs/visualizing_uncertainty_files/figure-html/butterfat-bars-1.png
Binary file modified docs/visualizing_uncertainty_files/figure-html/mpg-uncertain-1.png
55 changes: 32 additions & 23 deletions multi-panel_figures.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ggplot(filter(movies, year > 1905), aes(y = rating, x = votes)) +
panel.border = element_rect(
colour = "grey80", fill = NA, linetype = 1, size = 1.
),
plot.margin = margin(3, 5, 3, 0)
plot.margin = margin(3, 5, 3, 1.5)
)
```

Expand All @@ -96,11 +96,12 @@ p <- ggplot(BA_top_degrees, aes(year, perc)) +
geom_line(color = "#0072B2") +
facet_wrap(~field, labeller = label_wrap_gen(width = 25), ncol = 3,
scales = "free") +
ylab("percent") +
ylab("proportion of degrees") +
scale_y_continuous(labels = scales::percent_format(accuracy = .1)) +
theme_dviz_hgrid() +
theme(strip.text = element_text(margin = margin(7, 7, 3, 7)),
panel.spacing.x = grid::unit(14, "pt"),
plot.margin = margin(3.5, 14, 3.5, 0))
plot.margin = margin(3.5, 14, 3.5, 1.5))
stamp_bad(p)
```
Expand All @@ -114,12 +115,15 @@ ggplot(BA_top_degrees, aes(year, perc)) +
geom_line(color = "#0072B2") +
facet_wrap(~field, labeller = label_wrap_gen(width = 25), ncol = 3,
scales = "free") +
scale_y_continuous(limits = c(0, 0.241), expand = c(0, 0),
name = "percent") +
scale_y_continuous(
limits = c(0, 0.241), expand = c(0, 0),
name = "proportion of degrees",
labels = scales::percent_format(accuracy = 1)
) +
theme_dviz_hgrid() +
theme(strip.text = element_text(margin = margin(7, 7, 3, 7)),
panel.spacing.x = grid::unit(14, "pt"),
plot.margin = margin(3.5, 14, 3.5, 0))
plot.margin = margin(3.5, 14, 3.5, 1.5))
```

Expand Down Expand Up @@ -158,7 +162,7 @@ p1 <- ggplot(BA_totals, aes(year, total/1e6)) +
theme_dviz_hgrid() +
theme(axis.title = element_text(color = textcol),
axis.text = element_text(color = textcol),
plot.margin = margin(3, 7, 3, 0))
plot.margin = margin(3, 7, 3, 1.5))
BA_df %>% group_by(field) %>%
summarize(mean_perc = mean(perc)) %>%
Expand All @@ -178,10 +182,15 @@ p2 <- ggplot(BA_top_pairs, aes(x = year, y = perc)) +
expand = expand_scale(mult = c(0.1, 0.04)),
name = NULL,
position = "top") +
scale_y_continuous(limits = c(0.02, 0.22), expand = c(0, 0), name = "percent of degrees",
sec.axis = dup_axis(breaks = filter(BA_top_pairs, year == 2015)$perc + 0.0001,
labels = filter(BA_top_pairs, year == 2015)$field_wrapped,
name = NULL)) +
scale_y_continuous(
limits = c(0.02, 0.22), expand = c(0, 0),
name = "proportion of degrees",
labels = scales::percent_format(accuracy = 1),
sec.axis = dup_axis(
breaks = filter(BA_top_pairs, year == 2015)$perc + 0.0001,
labels = filter(BA_top_pairs, year == 2015)$field_wrapped,
name = NULL)
) +
theme_dviz_open() +
theme(axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
Expand All @@ -195,7 +204,7 @@ p2 <- ggplot(BA_top_pairs, aes(x = year, y = perc)) +
),
axis.line.y.right = element_blank(),
axis.ticks.y.right = element_blank(),
plot.margin = margin(3, 7, 3, 0))
plot.margin = margin(3, 7, 3, 1.5))
plot_grid(p1, p2, labels = "auto", rel_widths = c(1.2, 1), align = 'h')
```
Expand Down Expand Up @@ -236,7 +245,7 @@ p1 <- ggplot(athletes_df, aes(x = sex)) +
theme_dviz_hgrid(12, rel_small = 1) +
theme(axis.ticks.x = element_blank(),
#axis.ticks.length = grid::unit(0, "pt"),
plot.margin = margin(3, 6, 0, 0))
plot.margin = margin(3, 6, 0, 1.5))
p2 <- ggplot(athletes_df, aes(x = rcc, y = wcc, shape = sex, color = sex, fill = sex)) +
geom_point(size = 2.5) +
Expand All @@ -255,12 +264,12 @@ p2 <- ggplot(athletes_df, aes(x = rcc, y = wcc, shape = sex, color = sex, fill =
theme(legend.position = c(1, .1),
legend.justification = "right",
legend.box.background = element_rect(fill = "white", color = "white"),
plot.margin = margin(3, 0, 0, 0))
plot.margin = margin(3, 1.5, 0, 1.5))
p_row <- plot_grid(p1, p2, labels = "auto", align = 'h', rel_widths = c(0.7, 1)) +
draw_text("RBC count", x = 1, y = 0, size = 12, hjust = 1, vjust = -0.02,
family = dviz_font_family) +
theme(plot.margin = margin(0, 0, 6, 0))
theme(plot.margin = margin(0, 1.5, 6, 1.5))
p3 <- ggplot(athletes_df, aes(x = sport, y = pcBfat, color = fct_relevel(sex, "m"),
fill = fct_relevel(sex, "m"))) +
Expand All @@ -278,7 +287,7 @@ p3 <- ggplot(athletes_df, aes(x = sport, y = pcBfat, color = fct_relevel(sex, "m
)
stamp_bad(plot_grid(p_row, p3, ncol = 1, labels = c("", "c")) +
theme(plot.margin = margin(6, 12, 0, 0)))
theme(plot.margin = margin(6, 12, 0, 1.5)))
```

Figure \@ref(fig:athletes-composite-good) fixes all these issues. In this figure, female athletes are consistently shown in orange and to the left of male athletes, who are shown in blue. Notice how much easier it is to read this figure than Figure \@ref(fig:athletes-composite-inconsistent). When we use a consistent visual language, it doesn't take much mental effort to determine which visual elements in the different panels represent women and which men. Figure \@ref(fig:athletes-composite-inconsistent), on the other hand, can be quite confusing. In particular, on first glance it may generate the impression that men tend to have higher body fat percentages than women. Notice also that we need only a single legend in Figure \@ref(fig:athletes-composite-good) but needed two in Figure \@ref(fig:athletes-composite-inconsistent). Since the visual language is consistent, the same legend works for panels (b) and (c).
Expand All @@ -295,20 +304,20 @@ p1 <- ggplot(athletes_df, aes(x = sex, fill = sex)) +
theme(#axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
#axis.ticks.length = grid::unit(0, "pt"),
plot.margin = margin(3, 6, 0, 0))
plot.margin = margin(3, 6, 0, 1.5))
p2 <- ggplot(athletes_df, aes(x = rcc, y = wcc, fill = sex)) +
geom_point(pch = 21, color = "white", size = 2.5) +
scale_x_continuous(limits = c(3.8, 6.75), name = NULL) +
scale_y_continuous(limits = c(2.2, 11.), expand = c(0, 0), name = "WBC count") +
scale_fill_manual(values = c("#D55E00D0", "#0072B2D0"), guide = "none") +
theme_dviz_hgrid(12, rel_small = 1) +
theme(plot.margin = margin(3, 0, 0, 0))
theme(plot.margin = margin(3, 1.5, 0, 1.5))
p_row <- plot_grid(p1, p2, labels = "auto", align = 'h', rel_widths = c(0.7, 1)) +
draw_text("RBC count", x = 1, y = 0, size = 12, hjust = 1, vjust = -0.02,
family = dviz_font_family) +
theme(plot.margin = margin(0, 0, 6, 0))
theme(plot.margin = margin(0, 1.5, 6, 1.5))
GeomBP <- GeomBoxplot
GeomBP$draw_key <- draw_key_polygon
Expand All @@ -331,7 +340,7 @@ p3 <- ggplot(athletes_df, aes(x = sport, y = pcBfat, color = sex, fill = sex)) +
legend.justification = "right")
plot_grid(p_row, p3, ncol = 1, labels = c("", "c")) +
theme(plot.margin = margin(6, 12, 0, 0))
theme(plot.margin = margin(6, 12, 0, 1.5))
```

Finally, we need to pay attention to the alignment of individual figure panels in a compound figure. The axes and other graphical elements of the individual panels should all be aligned to each other. Getting the alignment right can be quite tricky, in particular if individual panels are prepared separately, possibly by different people and/or in different programs, and then pasted together in an image manipulation program. To draw your attention to such alignment issues, Figure \@ref(fig:athletes-composite-misaligned) shows a variation of Figure \@ref(fig:athletes-composite-good) where now all figure elements are slightly out of alignment. I have added axis lines to all panels of Figure \@ref(fig:athletes-composite-misaligned) to emphasize these alignment problems. Notice how no axis line is aligned with any other axis line for any other panel of the figure.
Expand All @@ -349,7 +358,7 @@ p1 <- ggplot(athletes_df, aes(x = sex, fill = sex)) +
theme(#axis.line.x = element_blank(),
#axis.ticks.x = element_blank(),
#axis.ticks.length = grid::unit(0, "pt"),
plot.margin = margin(3, 6, 6, 0))
plot.margin = margin(3, 6, 6, 1.5))
p2 <- ggplot(athletes_df, aes(x = rcc, y = wcc, fill = sex)) +
geom_point(pch = 21, color = "white", size = 2.5) +
Expand All @@ -358,7 +367,7 @@ p2 <- ggplot(athletes_df, aes(x = rcc, y = wcc, fill = sex)) +
scale_fill_manual(values = c("#D55E00D0", "#0072B2D0"), guide = "none") +
theme_dviz_open(12, rel_small = 1) +
background_grid(major = "y") +
theme(plot.margin = margin(3, 18, 0, 0))
theme(plot.margin = margin(3, 18, 0, 1.5))
p_row <- plot_grid(NULL, p1, p2, labels = c("", "a", "b"), nrow = 1,
rel_widths = c(0.03, 0.7, 1))
Expand All @@ -385,5 +394,5 @@ p3 <- ggplot(athletes_df, aes(x = sport, y = pcBfat, color = sex, fill = sex)) +
legend.justification = "right")
stamp_ugly(plot_grid(p_row, p3, ncol = 1, labels = c("", "c")) +
theme(plot.margin = margin(6, 12, 0, 0)))
theme(plot.margin = margin(6, 12, 0, 1.5)))
```
38 changes: 24 additions & 14 deletions no_3d.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cyls <- data.frame(cyl = factor(c(4, 6, 8)))
p <- ggplot(cyls, aes(cyl, cyl, color = cyl)) + geom_point() +
scale_color_manual(values = colors, name = "cylinders") +
theme_half_open(font_size = 12, font_family = dviz_font_family) +
theme_dviz_open(font_size = 12, font_family = dviz_font_family) +
theme(legend.position = "top",
legend.justification = "right")
legend <- get_legend(p)
Expand Down Expand Up @@ -121,16 +121,19 @@ p1 <- ggplot(mtcars, aes(x = disp, y = mpg, color = factor(cyl))) +
scale_color_manual(values = colors, name = "cylinders", guide = "none") +
xlab("displacement (cu. in.)") +
ylab("efficiency (mpg)") +
theme_half_open(12)
theme_dviz_open(12)
p2 <- ggplot(mtcars, aes(x = hp, y = mpg, color = factor(cyl))) +
geom_point(size = 1.5) +
scale_color_manual(values = colors, name = "cylinders") +
xlab("power (hp)") +
ylab("efficiency (mpg)") +
theme_half_open(12) +
theme(legend.position = c(1, 1),
legend.justification = c(1, 1))
theme_dviz_open(12) +
theme(
legend.position = c(1, 1),
legend.justification = c(1, 1),
legend.spacing.y = grid::unit(3, "pt")
)
plot_grid(p1, p2)
Expand All @@ -141,17 +144,24 @@ plot_grid(p1, p2)
```{r mtcars-2d-size, fig.width = 5.5, fig.asp = 0.75, fig.cap = '(ref:mtcars-2d-size)'}
p <- ggplot(mtcars, aes(x = disp, y = hp, size = mpg, fill = factor(cyl))) +
geom_point(color = "white", pch = 21) +
scale_fill_manual(values = colors, name = "cylinders",
guide = guide_legend(override.aes = list(size = 3))) +
scale_size(name = " mpg ",
range = c(1, 8),
limits = c(8, 40),
breaks = c(5, 10, 20, 40),
guide = guide_legend(override.aes = list(fill = "gray50"))) +
scale_fill_manual(
values = colors, name = "cylinders",
guide = guide_legend(override.aes = list(size = 3))
) +
scale_size(
name = " mpg ",
range = c(1, 8),
limits = c(8, 40),
breaks = c(5, 10, 20, 40),
guide = guide_legend(override.aes = list(fill = "gray50"))
) +
xlab("displacement (cu. in.)") +
ylab("power (hp)") +
theme_half_open() +
theme(legend.title.align = 0.5)
theme_dviz_open() +
theme(
legend.title.align = 0.5,
legend.spacing.y = grid::unit(4, "pt")
)
ggdraw(align_legend(p))
```
Expand Down

0 comments on commit 9c080cd

Please sign in to comment.