如何在R中绘制连续线?

时间:2016-05-01 11:16:37

标签: r plot

如何在需要连续样品线的地方绘制这种数据?样品A,B和C需要三条线;值在Y轴上,rec在X轴上。

mydata<- structure(list(samples = structure(c(1L, 2L, 3L, 1L, 2L, 3L), .Label = c("A", 
"B", "c"), class = "factor"), value = c(1, 8, 7, 2, 5, 9), rec = c(7158, 
6975, 6573, 1122, 2235, 229)), .Names = c("samples", "value", 
"rec"), class = "data.frame", row.names = c(NA, -6L))

1 个答案:

答案 0 :(得分:3)

您可以使用ggplot2

来实现
library(ggplot2)
ggplot(mydata, aes(x = rec, y = value)) + geom_line(aes(group = samples))