r - ggplot2 geom_errrorbar 不显示图形中一点的完整误差条
问题描述
我正在根据此数据框使用 ggplot2 进行绘图:
Control Stress days sd_control
X21 0.9702100 0.9343627 X21 0.001900535
X28 0.9666619 0.8595523 X28 0.014946893
X35 0.9165654 0.7160598 X35 0.072655343
X42 0.9208237 0.6668044 X42 0.050870831
X49 0.8766547 0.7660685 X49 0.073588197
X56 0.9599553 0.7937444 X56 0.041559836
X63 0.9736297 0.8188934 X63 0.003817743
情节的代码是:
ggplot(my_data, aes(x=days,y=Control,group=1)) +
geom_point(shape=22,color='grey',fill='grey',size=3) +
geom_line(color='grey') +
xlab('DAT') +
ylab('RWC') +
scale_y_continuous(labels = percent,limits = c(0.5,1), expand = c(0,0)) +
scale_x_discrete(expand = c(0.07, 0)) +
ggtitle('Relative Water Content') +
geom_errorbar(aes(ymax = Control-sd_control, ymin = Control+sd_control))
x56 处绘图的误差条不完整。关于如何解决这种行为的任何想法?
解决方案
问题在于您对 y 轴的限制。尝试limits
修改scale_y_continuous
:
ggplot(my_data, aes(x=days,y=Control,group=1)) +
geom_point(shape=22,color='grey',fill='grey',size=3) +
geom_line(color='grey') +
xlab('DAT') +
ylab('RWC') +
scale_y_continuous(labels = percent,limits = c(0.5,1.01), expand = c(0,0)) +
scale_x_discrete(expand = c(0.07, 0)) +
ggtitle('Relative Water Content') +
geom_errorbar(aes(ymax = Control-sd_control, ymin = Control+sd_control))
推荐阅读
- flutter - How to convert From DateTime to unix timestamp in Flutter or Dart in general
- html - 数据可视化:有选择地为形状设置动画,但不是 svg 组中的文本
- python - Why we need to use 'get_absolute_url()' instead of custom defined similar methods?
- c++ - 在编译时迭代检查函数是否存在
- javascript - 如何在highchart中删除额外的系列
- javascript - 在 Angular Web 应用程序上绕过不可见的 ReCaptcha
- java - 使用流根据键在键值对上应用不同的功能
- javascript - D3js服务器端鼠标悬停事件不起作用
- javascript - How to redirect login page to dashboard using ReactJS?
- bash - How can I sort urls in bash shell such as hostnames are evaluated before subdomain names?