Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading