R ggplot: suppress bottom of error bar on geom_bar

前端 未结 1 1954
失恋的感觉
失恋的感觉 2021-01-21 00:07

I\'m plotting bar plots with error bars but I can\'t figure out how to suppress the lower part of the error bar. Does anyone has an idea how I could do that?

This is my

相关标签:
1条回答
  • 2021-01-21 00:33

    I know that the post is old, but it is now when I front this problem. These options work if you want to add a geom_errorbar to a geom_bar, but if you want to plot a geom_point + geom_bar, an horizontal line will appear over your point.

    For solve that problem I have found a 'trap'.

    ggplot(data, (aes(x...) + geom_point() + 
    geom_errorbar(aes(ymin = upper, ymax = upper)) + 
    geom_linerange(aes(ymin = mean, ymax = upper))
    

    Using this code you will obtain only the upper line, because the lower line is overlapping the upper, and with geom_linerange you get the vertical line.

    0 讨论(0)
提交回复
热议问题