简体   繁体   中英

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

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.

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM