我认为这很简单。
我在 ggplot2 的表达式函数中使用粗体。
这对我来说很清楚并且有效。
但是当我将它与特殊字符一起使用时,例如mu*mol
具有μmol
or H[2]*O
具有2
作为下标,它不起作用。
实际上,它不会将特殊字符加粗。
我尝试使用我知道的粗体函数和 ggplot 中的表达式。
我只向您展示我用来设置标签的绘图代码的字符串。
scale_y_continuous(sec.axis = sec_axis(trans = ~ ./5, name = expression(bold(atop(H[2]*O,(mu*mol~m^bold("-2")~s^bold("-1"))))),breaks=c(-3,-1.5,0,1.5,3)),breaks=seq(-10,20,10))
In the figure you can see that μ
is not bold and the subscript 2
of H2O
is not bold.
使用单个就足够了bold
表达式中的语句,但是您必须用引号将每个下标和上标引起来。这仍然会留下你的希腊字母mu
无粗体,b/cplotmath
没有粗体符号字体(请参阅here https://stat.ethz.ch/pipermail/r-help/2010-March/232923.html)。但是,您可以通过替换来规避此问题mu
与 unicode 字符(你可以找到它们here http://kestrel.nmt.edu/~raymond/software/howtos/greekscape.xhtml).
这里我刚刚使用了标准mtcars
数据集。
library(ggplot2)
ggplot(mtcars, aes(x = wt, y = qsec)) +
geom_line() +
scale_y_continuous(sec.axis = sec_axis(trans = ~ ./5,
name = expression(bold(atop(H["2"]*O,("\u03bc"*mol~m^"-2"~s^"-1"))))))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)