错误栏结束丢失(Error bar ends missing)

系统教程 行业动态 更新时间:2024-06-14 16:57:40
错误栏结束丢失(Error bar ends missing)

以下示例代码:

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)

产生以下情节:

我一直无法弄清楚为什么最左边的错误栏末端没有'T'。

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.

最满意答案

注意警告:

Warning message: Removed 1 rows containing missing values (geom_path).

使用coord_cartesian指定限制而不丢弃数据:

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)

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)

更多推荐

本文发布于:2023-04-13 12:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/ecf71acc4cc629099ce41f7291ad6af3.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   结束   Error   missing   ends

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!