在y轴上绘制数据嵌入深度

问题描述 投票:0回答:1
我在R中有一个数据集,其中包含某些深度的物种,我正在尝试绘制它们,但我似乎无法使线路遵循深度,它想要遵循X轴数字(图形会更好地解释它)

虚拟数据: |深度|值| |:---- |:-------:| | 5 | 200 | | 15 | 100 | | 25 | 50 | | 35 | 100 | | 45 | 80 | | 55 | 40 | | 65 | 10 |

我试图像这样绘制它

ggplot(test, aes(x = value, y = depth)) + geom_line() + geom_point() + scale_y_reverse() + labs(title = "Sea Depth vs Value", x = "Value", y = "Sea Depth (cm)") + theme_minimal()

在该代码中,我得到了这个数字

enter image description here 但是我想得到这样的东西

enter image description here 任何帮助都非常感谢

您可以使用

geom_path
r ggplot2 plot
1个回答
0
投票
geom_line

。而后者将根据图上映射的变量连接点,将它们在数据中显示时连接点:

x

第二个选项将是使用
geom_path
来供

# Dataframe erstellen test <- data.frame( depth = c(5, 15, 25, 35, 45, 55, 65), value = c(200, 100, 50, 100, 80, 40, 10) ) library(ggplot2) ggplot(test, aes(x = value, y = depth)) + geom_path() + geom_point() + scale_y_reverse() + labs( title = "Sea Depth vs Value", x = "Value", y = "Sea Depth (cm)" ) + theme_minimal()
订单
orientation="y"

值:

geom_line

    

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