Skip to content

Use rel() more consistently in theme elements, take two #2173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggplot2 2.2.1.9000

* Use `rel()` to set line widths in theme defaults (@baptiste).

* `geom_density` drops groups with fewer than two data points and throws a
warning. For groups with two data points, the density values are now
calculated with `stats::density` (@karawoo, #2127).
Expand Down
32 changes: 16 additions & 16 deletions R/theme-defaults.r
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ theme_grey <- function(base_size = 11, base_family = "") {
panel.background = element_rect(fill = "grey92", colour = NA),
panel.border = element_blank(),
panel.grid.major = element_line(colour = "white"),
panel.grid.minor = element_line(colour = "white", size = 0.25),
panel.grid.minor = element_line(colour = "white", size = rel(0.5)),
panel.spacing = unit(half_line, "pt"),
panel.spacing.x = NULL,
panel.spacing.y = NULL,
Expand Down Expand Up @@ -186,11 +186,11 @@ theme_bw <- function(base_size = 11, base_family = "") {
panel.border = element_rect(fill = NA, colour = "grey20"),
# make gridlines dark, same contrast with white as in theme_grey
panel.grid.major = element_line(colour = "grey92"),
panel.grid.minor = element_line(colour = "grey92", size = 0.25),
panel.grid.minor = element_line(colour = "grey92", size = rel(0.5)),
# contour strips to match panel contour
strip.background = element_rect(fill = "grey85", colour = "grey20"),
# match legend key to background
legend.key = element_rect(fill = "white", colour=NA),
legend.key = element_rect(fill = "white", colour = NA),

complete = TRUE
)
Expand All @@ -205,14 +205,14 @@ theme_linedraw <- function(base_size = 11, base_family = "") {
theme(
# black text and ticks on the axes
axis.text = element_text(colour = "black", size = rel(0.8)),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.ticks = element_line(colour = "black", size = rel(0.5)),
# NB: match the *visual* thickness of axis ticks to the panel border
# 0.5 clipped looks like 0.25

# pure black panel border and grid lines, but thinner
panel.border = element_rect(fill = NA, colour = "black", size = 0.5),
panel.grid.major = element_line(colour = "black", size = 0.05),
panel.grid.minor = element_line(colour = "black", size = 0.025),
panel.border = element_rect(fill = NA, colour = "black", size = rel(1)),
panel.grid.major = element_line(colour = "black", size = rel(0.1)),
panel.grid.minor = element_line(colour = "black", size = rel(0.05)),

# strips with black background and white text
strip.background = element_rect(fill = "black"),
Expand All @@ -230,14 +230,14 @@ theme_light <- function(base_size = 11, base_family = "") {
theme(
# white panel with light grey border
panel.background = element_rect(fill = "white", colour = NA),
panel.border = element_rect(fill = NA, colour = "grey70", size = 0.5),
panel.border = element_rect(fill = NA, colour = "grey70", size = rel(1)),
# light grey, thinner gridlines
# => make them slightly darker to keep acceptable contrast
panel.grid.major = element_line(colour = "grey87", size = 0.25),
panel.grid.minor = element_line(colour = "grey87", size = 0.125),
panel.grid.major = element_line(colour = "grey87", size = rel(0.5)),
panel.grid.minor = element_line(colour = "grey87", size = rel(0.25)),

# match axes ticks thickness to gridlines and colour to panel border
axis.ticks = element_line(colour = "grey70", size = 0.25),
axis.ticks = element_line(colour = "grey70", size = rel(0.5)),

# match legend key to panel.background
legend.key = element_rect(fill = "white", colour = NA),
Expand All @@ -261,11 +261,11 @@ theme_dark <- function(base_size = 11, base_family = "") {
panel.background = element_rect(fill = "grey50", colour = NA),
# inverse grid lines contrast compared to theme_grey
# make them thinner and try to keep the same visual contrast as in theme_light
panel.grid.major = element_line(colour = "grey42", size = 0.25),
panel.grid.minor = element_line(colour = "grey42", size = 0.125),
panel.grid.major = element_line(colour = "grey42", size = rel(0.5)),
panel.grid.minor = element_line(colour = "grey42", size = rel(0.25)),

# match axes ticks thickness to gridlines
axis.ticks = element_line(colour = "grey20", size = 0.25),
axis.ticks = element_line(colour = "grey20", size = rel(0.5)),

# match legend key to panel.background
legend.key = element_rect(fill = "grey50", colour = NA),
Expand Down Expand Up @@ -307,13 +307,13 @@ theme_classic <- function(base_size = 11, base_family = ""){
panel.grid.minor = element_blank(),

# show axes
axis.line = element_line(colour = "black", size = 0.5),
axis.line = element_line(colour = "black", size = rel(1)),

# match legend key to panel.background
legend.key = element_blank(),

# simple, black and white strips
strip.background = element_rect(fill = "white", colour = "black", size = 1),
strip.background = element_rect(fill = "white", colour = "black", size = rel(2)),
# NB: size is 1 but clipped, it looks like the 0.5 of the axes

complete = TRUE
Expand Down