ylab()函数中的上标和下标

时间:2017-06-01 16:45:58

标签: rstudio

这段代码可能有点乱(刚刚开始使用R),但我正在寻找帮助来使用ggplot2和ylab()来获取下标和上标。

在实验室()中的mL之后我需要一个上标-1: chaptoplot = ggplot(chaptodat,aes(x = treatment,y = mean,shape = treatment))+ geom_errorbar(aes(ymin = mean-se,ymax = mean + se),color =“black”,width = .1, position = pd)+ geom_line(position = pd)+ geom_point(position = pd,size = 4)+ ylab(“Corrected haptoglobin \ nconcenration(mg mL)\ n”)+ theme_bw()+ theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank())+ theme_classic()+ theme(axis.text = element_text(color =“black”,size = 12))+ theme(axis.title = element_text(size = 12))+主题(legend.position =“none”)+ ylim(0.2,0.7)

对于这段代码,我需要在ylab()中的OD之后订阅405: natabplot = ggplot(natabdat,aes(x = bin,y = mean,shape = treatment))+ geom_errorbar(aes(ymin = mean-se,ymax = mean + se),color =“black”,width = .1, position = pd)+ geom_line(position = pd)+ geom_point(position = pd,size = 4)+ xlab(“\ n采样时间”)+ ylab(“总循环IgY \ n(校正OD)\ n”)+ theme_bw()+ theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank())+ theme_classic()+ theme(axis.text = element_text(color =“black”,size = 12)) +主题(axis.title = element_text(大小= 12))+主题(legend.position = “无”)

我尝试使用^“ - 1”和[“405”]进行搜索,但它要么不起作用,要么收到错误消息。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

下次您不需要编写所有代码,否则人们宁愿不阅读它。只需编写代码的重要部分,使用特殊代码块ctrl + k。

但是,你应该这样写:

chaptoplot = ggplot(chaptodat, aes(x=treatment, y=mean, shape=treatment)) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), colour="black", width=.1, position=pd) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), colour="black", width=.1, position=pd) +
geom_line(position=pd) +geom_point(position=pd, size=4) + 
ylab(expression("Corrected haptoglobin \nconcentration "("mg mL"^"-1")\n))) + 
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor=element_blank()) +
theme_classic() + 
theme(axis.text = element_text(colour = "black", size=12)) +
theme(axis.title=element_text(size=12)) +
theme(legend.position="none") +
ylim(0.2,0.7)

另一个应如下:

natabplot = ggplot(natabdat, aes(x=bin, y=mean, shape=treatment)) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), colour="black", width=.1, position=pd) +
geom_line(position=pd) +
geom_point(position=pd, size=4) +
xlab("\nTime of sampling") +
ylab(expression("Corrected haptoglobin \nconcentration"("mg mL"^"-1")))+
theme_bw() +
theme(panel.grid.major = element_blank(),panel.grid.minor=element_blank()) +
theme_classic()+theme(axis.text = element_text(colour = "black", size=12)) +
theme(axis.title=element_text(size=12)) +
theme(legend.position="none")