0

I am currently trying to plot some data with dots and lines. My dataframe has an own column (FarbDots) in which I specify my wanted colours. When I try to plot the data, geom_point takes the colours in the wanted order, while geom_lines() creates a total mess (see image).

I was not able to recreate the same effect in a sample data set. Any idea on how to get my colours in order while still specifying them within the geom_line()/ geom_point()?

This is the code I used for plotting: (with b specifying the dataset, x, y, and groups)

b + 
      geom_line(colour=Data_Biol_long$FarbDots)+ 
      geom_point(colour=Data_Biol_long$FarbDots)+
      scale_y_log10()+
      facet_grid(Analysis~., scale='free')

dots and lines should receive colour from same vector?!

zx8754
  • 52,746
  • 12
  • 114
  • 209
Becci
  • 3
  • 2
  • 1
    `colour=Data_Biol_long$FarbDots` isn't good practice and probably the reason for this issue. Use aesthetics, ie. do e.g. `geom_line(aes(colour=FarbDots)` and add a `scale_color_identity()`. If that still does not work or if you need more help I would suggest to provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. – stefan Oct 19 '22 at 09:32
  • Thanks,. This works for the top half of the plot, below it is still a mess. As said, I tried to reproduce it on an example data set but wouldn't get the same error. I am mainly confused by the geom_point looking exactly as I want it, while the geom_line with the same input does something entirely different. – Becci Oct 19 '22 at 09:42

0 Answers0