本文介绍了R ggplot Y轴中断设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我在代码中设置中断时遇到困难,我尝试添加中断= seq(0,100,by = 20),但似乎无法使其正常工作。基本上我希望Y轴从0到100,并且每20次打勾。 YearlyCI 车站年份CI se M-25 2013 56.57098 1.4481561 M-45 2013 32.39036 0.6567439 X-2 2013 37.87488 0.7451653 M- 25 2008 74.5 2.4 M-45 2008 41.6 1.1 M-25 2004 82.2 1.9 M-45 2004 60.6 1.0 ') library(ggplot2) ggplot(YearlyCI,aes(x = Year,y = CI,color = Station,group = Station))+ geom_errorbar(aes(ymin = CI-se,ymax = CI + se),color =black,width = .2)+ geom_line(size = .8)+ geom_point(size = 4,shape = 18)+ coord_cartesian ylim = c(0,100))+ xlab(Year)+ ylab(平均条件指数)+ 实验室(fill =)+ theme_bw()+ theme(legend.justification = c(1,1),legend.position = c(1,1)) 解决方案 您需要添加 + scale_y_continuous(breaks = seq(0,100,by = 20)) I'm having difficulty setting the breaks in my code, I've tried adding breaks=seq(0, 100, by=20) but just can't seem to get it to work right. Essentially I want the Y axis to go from 0-100 with ticks every 20. YearlyCI <- read.table(header=T, text=' Station Year CI se M-25 2013 56.57098 1.4481561 M-45 2013 32.39036 0.6567439 X-2 2013 37.87488 0.7451653 M-25 2008 74.5 2.4 M-45 2008 41.6 1.1 M-25 2004 82.2 1.9 M-45 2004 60.6 1.0 ')library(ggplot2)ggplot(YearlyCI, aes(x=Year, y=CI, colour=Station,group=Station)) + geom_errorbar(aes(ymin=CI-se, ymax=CI+se), colour="black", width=.2) + geom_line(size=.8) + geom_point(size=4, shape=18) + coord_cartesian(ylim = c(0, 100)) + xlab("Year") + ylab("Mean Condition Index") + labs(fill="") + theme_bw() + theme(legend.justification=c(1,1), legend.position=c(1,1)) 解决方案 You need to add + scale_y_continuous(breaks = seq(0, 100, by = 20)) 这篇关于R ggplot Y轴中断设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 02:46