Setting theme() after using a complete theme (like theme_minimal()) no longer works
Closed this issue · 1 comments
thomasjwood commented
It used to be the behavior of ggplot that you could use a default theme (like theme_minimal()) and then specify a further change with a subsequent use of theme(). That no longer seems to be the case.
library(tidyverse)
library(ggtext)
ggplot(
economics, aes(date, unemploy)
) +
geom_line() +
scale_x_date(
breaks = seq.Date(
"1970-01-01" %>% as.Date,
"2012-01-01" %>% as.Date,
length.out = 5
),
labels = str_c(
"**",
seq(1970, 2010, by = 10),
"**"
)
) +
theme(
axis.text.x = element_markdown()
)
Now, imagine if I wanted to keep the markdown for the x axis labels, but use theme_minimal() otherwise. You formerly could use
ggplot(
economics, aes(date, unemploy)
) +
geom_line() +
scale_x_date(
breaks = seq.Date(
"1970-01-01" %>% as.Date,
"2012-01-01" %>% as.Date,
length.out = 5
),
labels = str_c(
"**",
seq(1970, 2010, by = 10),
"**"
)
) +
theme_minimal() +
theme(
axis.text.x = element_markdown()
)
but now it returns (ie the theme(axis.text.x = ....) is ignored.)
How can one set a theme() element after using a complete theme?
teunbrand commented
It works if you set axis.text.x.bottom. I'm sure this is due to a pivot towards S7 and element inheritance being a bit rough.
