'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() 


Solution 1:[1]

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()
  )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MKR