Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Rstudio中的ggplot2中添加主标题和操作轴标签_R_Ggplot2_Label_Bar Chart - Fatal编程技术网

如何在Rstudio中的ggplot2中添加主标题和操作轴标签

如何在Rstudio中的ggplot2中添加主标题和操作轴标签,r,ggplot2,label,bar-chart,R,Ggplot2,Label,Bar Chart,我是R新手,正在使用Rstudio 我有一个用于绘制条形图()的GGPLOT2R脚本,我创建了它,但它有两个错误,看起来非常简单,但我无法解决它们: 1)在x轴标签中,它必须是函数类,但它是函数类(没有空格)。当我添加空格时,它会显示这个错误->:错误:在“p尝试添加xlab和ggtitle中出现意外符号: p <- ggplot(data=dat, aes(x=FunctionClass, y=Frequency, fill=legend))+ geom_bar(stat="identi

我是R新手,正在使用Rstudio

我有一个用于绘制条形图()的GGPLOT2R脚本,我创建了它,但它有两个错误,看起来非常简单,但我无法解决它们:


1)x轴标签中,它必须是函数类,但它是函数类(没有空格)。当我添加空格时,它会显示这个错误->:错误:在“p尝试添加
xlab
ggtitle
中出现意外符号:

p <- ggplot(data=dat, aes(x=FunctionClass, y=Frequency, fill=legend))+
geom_bar(stat="identity", position=position_dodge(), colour="seashell")
p + guides (fill = guide_legend(ncol = 1))+
xlab("Factor Class")+
ggtitle("Plant Growth")

p太棒了!亲爱的朋友谢谢你。它解决了我的问题。我在这个(杀手)图上花了20多个小时。我可以问你一些其他问题吗?在我以前的“barplot()”脚本中,我有一行代码显示每个条的不同光谱->“col=c(fill=rainbow(25)),“这种彩虹颜色与ggplot2的颜色光谱不同。在我最近的ggplot2脚本中,有没有办法使用以红色开头的彩虹光谱而不是以橙色开头的ggplot2光谱。ThanksHi,如何更改ggplot fill()的颜色光谱?在我的“barplot()”脚本中,我有一行代码显示了每个条的不同颜色光谱->“col=c(fill=rainbow(25)),”而这个彩虹颜色与ggplot2的颜色光谱不同。在我最近的ggplot2脚本中,有没有办法使用以红色开头的彩虹光谱而不是以橙色开头的ggplot2光谱?
p <- ggplot(data=dat, aes(x=FunctionClass, y=Frequency, fill=legend))+
geom_bar(stat="identity", position=position_dodge(), colour="seashell")
p + guides (fill = guide_legend(ncol = 1))+
xlab("Factor Class")+
ggtitle("Plant Growth")