r - 垂直中心线
问题描述
对于以下示例,我想在 x 轴的值为 1 处添加一条垂直中心线。我试过geom_estci
(http://ggepi.lukewjohnston.com/reference/geom_estci.html),但我的 R 没有找到geom_estci
功能。我安装了库 ggplot2 和扫帚。我试图安装 ggepi 库。但它不适用于 R 版本 3.6.1。对于以下示例,如何在 x=1 处添加垂直中心线?
d=data.frame(drink=c("coffee","tea","water"), mean=c(3,6,2), lower=c(2.6,5.6,1.8),
upper=c(3.5,6.3,2.8))
ggplot() +
geom_errorbarh(data=d, mapping=aes(y=drink, x=upper, xmin=upper, xmax=lower), height=0.2, size=1,
color="blue") +
geom_point(data=d, mapping=aes(y=drink, x=mean), size=4, shape=21, fill="white")
解决方案
尝试添加geom_vline(xintercept = 1)
.
ggplot() +
geom_errorbarh(data=d, mapping=aes(y=drink, x=upper, xmin=upper, xmax=lower), height=0.2, size=1,
color="blue") +
geom_point(data=d, mapping=aes(y=drink, x=mean), size=4, shape=21, fill="white") +
geom_vline(xintercept = 1)
推荐阅读
- windows - 通过命令提示符的 Python 程序不允许 > 或 < 作为输入
- spring-boot - Springboot Ehcache 加载数据
- apache-flink - Flink Web UI:如何从 flink Web UI 中删除“取消”按钮
- python - Keras 模型从数小时内预测体验
- python - 如何使用 Keras/Tensorflow 在两点获得渐变
- java - 在 AnchorPane JavaFX 中的窗格中缩放节点
- python - 运行脚本时出错:Google Speech API
- python-3.x - 我只是“移动”图像,它的元数据会改变......
- unity3d - Unity 3d Nav Mesh Agent 无法以步行速度爬上台阶
- java - 我需要帮助来使用 im4java API 将 png 图像的白色背景替换为透明,而不是使用命令行