本文介绍了错误栏结束丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 以下示例代码: require(ggplot2) stats< - data。帧(Day = 0:5,Mean = c(3.2,2.7,0.8,0.2,0,0),Q10 = 0.0,Q90 = c(7.48,4.0,2.2,1.2,0,0)) plot geom_point(size = 4)+ geom_line(size = 1.5)+ geom_errorbar(aes(ymin = Q10,ymax = Q90),width = 0.2)+ ggtitle(示例)+ ylab(疼痛评分)+ scale_x_continuous ,expand = c(0.02,0),limits = c(0,15),breaks = 0:15,labels = c(DOS,1:15))+ scale_y_continuous(Pain Score, expand = c(0.02,0),limits = c(0,10),breaks = 0:10) print(plot) 产生如下图: 我一直无法弄清楚为什么最左边的错误栏在结尾处没有'T'。 解决方案请注意以下警告: 警告信息:删除了包含缺失值(geom_path)的1行。 使用 coord_cartesian 指定限制而不丢弃数据: plot geom_point (size = 4)+ geom_line(size = 1.5)+ geom_errorbar(aes(ymin = Q10,ymax = Q90),width = 0.2)+ ggtitle(Example)+ ylab(疼痛评分)+ scale_x_continuous(Day,breaks = 0:15,labels = c(DOS,1:15))+ scale_y_continuous得分,休息= 0:10)+ coord_cartesian(xlim = c(-0.3,15.3),ylim = c(-0.3,10.3)) print(plot) The following example code:require(ggplot2)stats <- data.frame(Day=0:5, Mean=c(3.2, 2.7, 0.8, 0.2, 0, 0), Q10=0.0, Q90=c(7.48, 4.0, 2.2, 1.2, 0, 0))plot <- ggplot(stats, aes(x=Day, y=Mean)) + geom_point(size=4) + geom_line(size=1.5) + geom_errorbar(aes(ymin=Q10, ymax=Q90), width=0.2) + ggtitle("Example") + ylab("Pain Score") + scale_x_continuous("Day", expand=c(0.02,0), limits=c(0,15), breaks=0:15, labels=c("DOS", 1:15)) + scale_y_continuous("Pain Score", expand=c(0.02,0), limits=c(0,10), breaks=0:10)print(plot)Produces the following plot:I've been unable to work out why the left-most error bar has no 'T' on the ends. 解决方案 Note the warning:Warning message:Removed 1 rows containing missing values (geom_path).Use coord_cartesian to specify limits without discarding data:plot <- ggplot(stats, aes(x=Day, y=Mean)) + geom_point(size=4) + geom_line(size=1.5) + geom_errorbar(aes(ymin=Q10, ymax=Q90), width=0.2) + ggtitle("Example") + ylab("Pain Score") + scale_x_continuous("Day", breaks=0:15, labels=c("DOS", 1:15)) + scale_y_continuous("Pain Score", breaks=0:10) + coord_cartesian(xlim = c(-0.3, 15.3), ylim = c(-0.3,10.3))print(plot) 这篇关于错误栏结束丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
05-27 22:38
查看更多