r - 按 y 轴上的位置顺序连接 ggplot 中的点
问题描述
在此处输入链接描述我想参考 DEPTH(m)(y 轴)而不是参考 VMR(x 轴)连接 ggplot 中的点。
这是我正在使用的代码:
sp<- ggplot(profiles, aes(x=mean_VLP_ml/avg_cells_ml, y=depth_m)) +
geom_point(aes(col=avg_cells_ml, size=mean_VLP_ml)) +
ggtitle("Virus to microbe ratio (VMR) with depth (m)") +
xlab("VMR") +
ylab("Depth_m") +
theme(axis.title.y = element_blank()) + scale_y_reverse() +
expand_limits(y=c(3, 21))
我怎样才能做到这一点?我已经用谷歌链接附加了数据集。
解决方案
如果没有数据集的示例,我猜测沿着 y 轴重新排序数据然后添加 geom_path...
sp <- profiles %>%
arrange(depth_m) %>%
ggplot(aes(x=mean_VLP_ml/avg_cells_ml, y=depth_m)) +
geom_point(aes(col=avg_cells_ml, size=mean_VLP_ml)) +
geom_path() +
ggtitle("Virus to microbe ratio (VMR) with depth (m)") +
xlab("VMR") +
ylab("Depth_m") +
theme(axis.title.y = element_blank()) + scale_y_reverse() +
expand_limits(y=c(3, 21))
类似于
sp <- mtcars %>%
arrange(hp) %>%
ggplot(aes(x=disp, y=hp)) +
geom_point() +
geom_path()
和
sp <- mtcars %>%
arrange(disp) %>%
ggplot(aes(x=disp, y=hp)) +
geom_point() +
geom_path()
推荐阅读
- python - 检测正则表达式中的拉丁字符
- android - BottomNavigationView 不突出显示自定义图标
- google-sheets - #姓名?Google 表格数据透视表计算字段出错
- java - java - 如何使用来自不同数据类型的其他列表的值填充java中的列表?
- python - 迭代嵌套列表中的值
- android - 如何检查 ArrayList 是否包含特定值
- docker - Docker-compose filebeat连接问题到logstash
- sql - 运行时错误 3061 预期参数太少 4
- javascript - Storybook 调用函数,它是组件的一个 prop
- python - 如何在 Python 中将具有随机名称的文件从一个文件夹移动到另一个文件夹?