[英]ggplot2, multiple variables for a line plot
I am trying to plot a line graph in R with multiple variables as the following data frame: Data Frame 我正在尝试在R中绘制一个带有多个变量的折线图,作为以下数据框: 数据框
I would like to get a plot as the next one: Plot 我想作为下一个情节: 情节
I have tried different methods but not being able to get this done, any suggestion? 我尝试了不同的方法,但无法完成此工作,有什么建议吗?
This should get you started, but I would tend to agree with Michael that a line plot may not be the way to go. 这应该可以帮助您入门,但是我倾向于与Michael达成一致意见,认为行进图可能不是走的路。
test <- data.frame(Name = c('M','D','T','H','P'),
Ball_Control = c(48,31,23,34,22),
Dribbling = c(30,13,13,10,12),
Marking = c(10,13,11,12,11),
Sliding_Tackle = c(11,13,16,18,12))
library(ggplot2)
library(tidyr)
df.gathered <- gather(test,key = 'Parameter',value = 'Value',2:5)
ggplot(df.gathered, aes(x = Parameter, y = Value, group = Name, col = Name))+geom_line()+
scale_y_continuous(limits = c(0,60), breaks = seq(0,60,10))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.