1

I am having a very simple logical problem in ggplot. Please see the attached graph. Graph attached here

I want multiple lines in each facet, I am getting only one line. Each set of values need to be connected individually across the Attribute. The code I have used is :

library(ggplot2)
h <- ggplot(data = df, mapping = aes(Attribute, Values, colour = Classe)) 
h + geom_point(size = 0.7) + geom_line() + facet_wrap( ~ Classe, scales = "free_x")
bs93
  • 1,236
  • 6
  • 10
Mumid
  • 21
  • 1
  • 7
  • 2
    Can you dput(df) and add output to post? As in this example: https://stackoverflow.com/a/49995752/11437205 – bs93 Apr 10 '20 at 12:12
  • 3
    Seems you should add a grouping variable in `geom_line()` that indicates what observations belong together. – teunbrand Apr 10 '20 at 12:27
  • It's a bit unclear what you are looking for in your end result. If you want all the lines in the same plot, you don't need the facets. You've already setup in `aes(...)` the variable to separate color, so if you take what you have and remove `facet_wrap(...)`, you'll end up with one plot that contains all line and point colors together. If you want to facet your data, then you can add back in the `facet_wrap(...)` function, but you should choose another variable to use for faceting: something else in place of "Classe". – chemdork123 Apr 10 '20 at 13:29

0 Answers0