Unique geomline in facet_wrap

How can I create a unique geomline for each group?

Here is the code which I created with geom_point.
I would like to remove the geom_point and created within geom_line.

library(tidyr)
library(ggplot2)
library(dplyr)

set.seed(100)


df=data.frame(
  ty=as.factor(rep(c(rep("a",6), rep("b",6),rep("c",6)),2)),
  time=as.factor( c (rep("present",18), rep("fut",18))),
  
  RI=as.factor(rep(c("one","two","three","four","five","six"),6)),
  value=sample(100,36))

df %>% 
  ggplot(aes(x = ty, y= value,  group = time)) +
  geom_line()+
  geom_point(aes(shape=time), 
             size = 3)+
  facet_wrap(facets = vars(RI))

Is this what you want?

df %>% 
  ggplot(aes(x = ty, y= value,  group = time)) +
  geom_line(aes(linetype = time)) +
  # geom_point(aes(shape=time), 
  #            size = 3) +
  facet_wrap(facets = vars(RI))

3 Likes

I am not sure I understand your goal. Does coloring the lines meet your needs?

set.seed(100)
library(ggplot2)

df=data.frame(
  ty=as.factor(rep(c(rep("a",6), rep("b",6),rep("c",6)),2)),
  time=as.factor( c (rep("present",18), rep("fut",18))),
  
  RI=as.factor(rep(c("one","two","three","four","five","six"),6)),
  value=sample(100,36))


  ggplot(df, aes(x = ty, y= value,  group = time, color = time)) +
  geom_line()+
  facet_wrap(facets = vars(RI))

Created on 2022-10-13 with reprex v2.0.2

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.