Getting greek character in plot axis [duplicate]

别等时光非礼了梦想. 提交于 2019-12-11 08:37:28

问题


I am making barplots for different metal concentration in various materials, and need the axis to say μg/g. I've searched for how to implement greek characters into different plots, but I don't seem able to actually do so. It looks like I should be able to use (expression(paste)) - can anyone help me?

This is an extract of my current script:

BP.Ag <- ggplot(data=dat, aes(x=Material, y=Ag, fill=Sample.Material)) +  
  geom_bar(stat="identity", position="dodge") + theme_bw() + 
  scale_fill_brewer(palette = "Set1") + ylab("Silver (μg/g)") + guides(fill=FALSE) + theme(axis.text.x = element_text(angle = 45, hjust = 1))

Thanks!


回答1:


Have you tried the UTF-8 for µ ("\u00B5"):

>cat("\u00B5")
µ

In your plot you could use:

ylab("Silver (\u00B5g/g)")



回答2:


A similar question was asked here: Adding greek character to axis title

Your ylab should be something like +ylab(expression(paste("Silver ", mu,"g/g")))



来源:https://stackoverflow.com/questions/43112094/getting-greek-character-in-plot-axis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!