Home > Enterprise >  Define seperate aesthetics for geom_smooth when grouping data
Define seperate aesthetics for geom_smooth when grouping data

Time:09-22

I have some batch test data which was performed under different mixing conditions.

While I have managed to group the data, I am not sure how to define different aethitics for the geom_smooth lines.

Plot


M3<- ggplot(subset(VFA2, VFA %in% "HPr"),  aes(x = Time, y = value, group = mix, shape = Test, colour = Test)) geom_point(size = 6, colour = "purple4") 
  labs(x = "Anaerobic Time (h)\n Continuous Mixing", y = "HPr Concentration\n(mg HPr/L)") theme(panel.background = element_rect(fill = "White", colour = "grey"),panel.grid.major = element_line(color = 'grey'), legend.position="bottom", text= element_text(size = 28, family = "Arial")) 
  scale_x_discrete(breaks = factor(VFA2$Time), expand = c(-0.25,2)) scale_y_continuous(limits = c(-0.25, 60),breaks = c(0, 10,20, 30, 40, 50, 60)) [![enter image description here][1]][1] scale_shape_manual(values = c(0,1,2,5,7,13,14,9))
M3<- M3   geom_smooth(method= "gam", formula = y~poly(x,4), se = F, colour = "black", linetype = "dashed")

CodePudding user response:

Is this what you are looking for :

M3<- ggplot(subset(VFA2, VFA %in% "HPr"), aes(x = Time, y = value, group = mix, shape = Test)) 
  geom_point(size = 6, colour = "purple4") 
  geom_smooth(aes(colour=mix), method= "gam", formula = y~poly(x,4), se = F, linetype = "dashed") 
  labs(x = "Anaerobic Time (h)\n Continuous Mixing", y = "HPr Concentration\n(mg HPr/L)") 
  theme(panel.background = element_rect(fill = "White", colour = "grey"),panel.grid.major = element_line(color = 'grey'), legend.position="bottom", text= element_text(size = 28, family = "Arial")) 
  scale_x_discrete(breaks = factor(VFA2$Time), expand = c(-0.25,2)) 
  scale_y_continuous(limits = c(-0.25, 60),breaks = c(0, 10,20, 30, 40, 50, 60)) 
  scale_shape_manual(values = c(0,1,2,5,7,13,14,9)) 
  scale_color_manual(values = c("black", "red"))
  • Related