Eric Nilsen
Eric Nilsen

Reputation: 101

Showing colour legend in a theme containing "legend.title = element_blank()"

I'm using the ggthemes "theme_exel_new" theme for a plot, which hides the title of the colour legend through the code legend.title = element_blank() in the function. I've attempted to get the title back by adding theme_excel_new(legend.title = waiver()), returning an unused argument error, as well as specifying a scale through scale_color_viridis(name = "M") which shows no effect at all.

Is there any way as to get the title back?

Reprex:

library(ggplot)
library(ggthemes)
ggplot(mtcars, aes(mpg, disp, colour = gear)) +
geom_point() +
theme_excel_new() 

Upvotes: 0

Views: 96

Answers (1)

MKR
MKR

Reputation: 1700

You can overwrite the theme again with theme().

library(ggplot)
library(ggthemes)
ggplot(mtcars, aes(mpg, disp, colour = gear)) +
  geom_point() +
  theme_excel_new()  +
  theme(
    legend.title = element_text()
  )

Upvotes: 1

Related Questions