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

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

问题描述

有什么办法可以改变轴标题部分的样式,同时保持其余部分不变?就我而言,我怎么能斜体
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天全站免登陆