虚拟数据: |深度|值| |:---- |:-------:| | 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()
在该代码中,我得到了这个数字
您可以使用
geom_path
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