Ggplotly-仅显示errorbar

问题描述 投票:0回答:1
。我的偏爱是仅显示错误栏的顶部。在

ggplotly

中,我简单地将errorbar的
ggplot2
指定为栏的值,然后首先绘制误差键,以便底部晶须隐藏在
y_min
后面。但是,一旦我通过
geom_bar
运行曲线,则在顶部显示了错误栏。有没有办法不显示底部晶须?我搜索了更改2个轨迹的顺序或“唯一”错误栏的选项的方法,但找不到任何东西。
ggplotly
    
                
thressmumand可以用一种方法来破解绘图对象以移动错误栏,使其在栏下方,尽管更简单的解决方案可能是仅绘制您想要可见的对象。您可以通过在Ymax和Y和YMAX之间的段绘制零高度错误栏来做到这一点。这样,层顺序就无关紧要。
library(dplyr) library(ggplot2) library(plotly) df <- data.frame(y = c(5, 10), group = c("a", "b")) p <- ggplot(df) + geom_errorbar(aes(x = group, ymin = y, ymax = y + 10), linewidth = 0.1, width = 0.7) + geom_bar(aes(x = group, y = y), stat = "identity", fill = "lightgrey") # only top whisker is shown p # both top and bottom are showing ggplotly(p)

r ggplot2 ggplotly
1个回答
0
投票


最新问题
© www.soinside.com 2019 - 2025. All rights reserved.