[英]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.我正在为 plot 使用 ggthemes“theme_exel_new”主题,它通过 function 中的代码legend.title = element_blank()
隐藏了颜色图例的标题。我试图通过添加theme_excel_new(legend.title = waiver())
,返回一个未使用的参数错误,以及通过scale_color_viridis(name = "M")
指定一个比例,这完全没有效果。
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()
You can overwrite the theme again with theme()
.您可以使用theme()
再次覆盖主题。
library(ggplot)
library(ggthemes)
ggplot(mtcars, aes(mpg, disp, colour = gear)) +
geom_point() +
theme_excel_new() +
theme(
legend.title = element_text()
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.