我有一个数据框datas
,我想绘制每个坐标,下面是我的代码。
有没有一种方法可以不为我的所有列写所有geom_line()
,因为有时我的Df中只有10列
library(ggplot2)
g = ggplot(datas , aes(x = -seq(500,0,by = -1), y= value , color = variable ) ) +
geom_line(aes(y = V1, col = "1")) +
geom_line(aes(y = V2, col = "2")) +
geom_line(aes(y = V3, col = "3")) +
geom_line(aes(y = V4, col = "4")) +
geom_line(aes(y = V5, col = "5")) +
geom_line(aes(y = V6, col = "6")) +
geom_line(aes(y = V7, col = "7")) +
geom_line(aes(y = V8, col = "8")) +
geom_line(aes(y = V9, col = "9")) +
geom_line(aes(y = V10, col = "10")) +
geom_line(aes(y = V11, col = "11")) +
geom_line(aes(y = V12, col = "12")) +
geom_line(aes(y = V13, col = "13")) +
geom_line(aes(y = V14, col = "14")) +
geom_line(aes(y = V15, col = "15")) +
geom_line(aes(y = V16, col = "16")) +
geom_line(aes(y = V17, col = "17")) +
geom_line(aes(y = V18, col = "18"))