Home > other >  How to have line chart "skip" data points
How to have line chart "skip" data points

Time:10-13

I have a unique issue. I have 4 people jump 3 times a week using a mat. I then take the max from each week a plot it. Well one of the 4 people wasn't able to show up for 2 weeks, but I still want them included in the line chart for a jump overview, but I keep getting the error "Error: Insufficient values in manual scale. 4 needed but only 3 provided."

I have attached a picture of the graph and what the code is. In the picture the person who missed 2 weeks isn't included, so you can see what I want the graph to look like, just with the person added in.

enter image description here

Jump_vel_tracking <- ggplot(Jump_tibble, aes(x = game, y = daily_max_vel, color = athlete))   
scale_color_manual(values = c("red" , "blue", "purple"))  
geom_point()   
geom_line(aes(group = athlete))   
scale_y_continuous(breaks = seq(from = 3.0, to = 3.8, by = 0.1), limits = c(3.0, 3.8))   
labs(x = 'Game', y = 'Peak Velocity (m/s)', title = "Season CMJ Peak Velocity")  
theme(panel.background = element_rect (fill = 'gray88', colour = 'orange'))   
theme(plot.background = element_rect (fill = 'orange', color = 'orange'))  
theme(panel.grid = element_blank())  
theme(legend.position = 'none',
      legend.title = element_blank(),
      legend.background = element_rect(fill = 'orange'),
      legend.key = element_rect(fill = 'orange'))  
theme(axis.text.x = element_text(size = 10, angle = 0))  
theme(axis.title.x=element_blank())

Jump_vel_tracking

enter code here

CodePudding user response:

The error Error: Insufficient values in manual scale. 4 needed but only 3 provided. occurs when you have not supplied enough colours in your scale_color_manual for all the levels in a factor.

So you need a fourth colour if your athlete factor has four values in the dataset.

Edit - also to me (as a slightly colourblind person) that purple and blue are almost indistinguishable so maybe choose a different colour?

  • Related