使ggplot中的y轴标签变为粗体(x轴设置为粗体,但y轴标签不变) [英] making y-axis labels bold in ggplot (x-axis is set bold but y-axis label doesn't change)
本文介绍了使ggplot中的y轴标签变为粗体(x轴设置为粗体,但y轴标签不变)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试设置轴标签,并在ggplot中打勾粗体,但y轴标签未设置为粗体.请提出我应该添加到脚本中的内容.以下是可重现的示例.我确实需要"atop"命令来设置y轴标签字符串,如下例所示.
I am trying to set axis labels and ticks bold in ggplot but y-axis labels is not setting to bold. Please suggest what I should add to the script. Below is a reproducible example. I do need 'atop' command to set y-axis labels string as in the example below.
先谢谢了.
library(ggplot2)
chart <- ggplot(diamonds, aes(x = table, fill = clarity)) +
geom_histogram() +
scale_x_continuous('Month') +
scale_y_continuous(expression(atop('ET (W'~m^-2~')')))
chart<-chart+theme(axis.title.y = element_text(colour="grey20",size=20,face="bold"),
axis.text.x = element_text(colour="grey20",size=20,face="bold"),
axis.text.y = element_text(colour="grey20",size=20,face="bold"),
axis.title.x = element_text(colour="grey20",size=20,face="bold"))
print(chart)
推荐答案
我遇到了类似的问题,并使它起作用:
I was having a similar problem and got this to work:
ylab(expression(atop(bold('ET (W'~m^-2~')'), paste(bold('something else'[here])))))
希望有帮助.
这篇关于使ggplot中的y轴标签变为粗体(x轴设置为粗体,但y轴标签不变)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文