如何将轴标题的一部分(一个或两个单词)斜体化 [英] How to italicize part (one or two words) of an axis title

查看:88
本文介绍了如何将轴标题的一部分(一个或两个单词)斜体化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以更改轴标题的一部分样式,同时保持其余部分不变?就我而言,如何斜体
y轴标题中的细菌X"?据我所知,命令theme(axis.title.y=element_text(face="italic"))只能更改整个y-aixs标题,对吗?

Is there any way to change the style of part of an axis title while keep the rest part unchanged? In my case, How could I italicize
"bacteria X" in the y-axis title? To my knowledge, the command theme(axis.title.y=element_text(face="italic")) can only change the whole y-aixs title, is it?

ggplot(fig1,aes(x=cf,y=Freq,fill=Var1)) +
geom_bar(stat="identity") +
labs(x="Groups",y="No. of bacteria X isolates with corresponding types",fill="Var1") +
theme(axis.title.y=element_text(face="italic"))

推荐答案

您可以这样表达:

my_y_title <- expression(paste("No. of ", italic("bacteria X"), " isolates with corresponding types"))
.... + labs(y=my_y_title)

这篇关于如何将轴标题的一部分(一个或两个单词)斜体化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆