Skip to main content
Notice added Recommended answer in R Language by Kat
added 8 characters in body
Source Link
Sven Hohenstein
  • 81.4k
  • 17
  • 148
  • 172

You need to use identical name and labels values for both shape and colour scale.

pd <- position_dodge(.65)
ggplot(data = data,aes(x= year, y = beta, colour = group2, shape = group2)) +    
  geom_point(position = pd, size = 4) +
  geom_errorbar(aes(ymin = lcl, ymax = ucl), colour = "black", width = 0.5, position = pd) +
  scale_colour_manual(name="Treatmentname = "Treatment & State",
                      labels = c("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"),
                      values=cvalues = c("blue", "red", "blue", "red")) +   
  scale_shape_manual(name="Treatmentname = "Treatment & State",
                     labels = c("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"),
                     values=cvalues = c(19, 19, 17, 17))

enter image description here

You need to use identical name and labels values for both shape and colour scale.

pd <- position_dodge(.65)
ggplot(data = data,aes(x= year, y = beta, colour = group2, shape = group2)) +    
  geom_point(position = pd, size = 4) +
  geom_errorbar(aes(ymin = lcl, ymax = ucl), colour = "black", width = 0.5, position = pd) +
  scale_colour_manual(name="Treatment & State",
                      labels = c("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"),
                      values=c("blue", "red", "blue", "red")) +   
  scale_shape_manual(name="Treatment & State",
                     labels = c("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"),
                     values=c(19, 19, 17, 17))

enter image description here

You need to use identical name and labels values for both shape and colour scale.

pd <- position_dodge(.65)
ggplot(data = data,aes(x= year, y = beta, colour = group2, shape = group2)) +    
  geom_point(position = pd, size = 4) +
  geom_errorbar(aes(ymin = lcl, ymax = ucl), colour = "black", width = 0.5, position = pd) +
  scale_colour_manual(name = "Treatment & State",
                      labels = c("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"),
                      values = c("blue", "red", "blue", "red")) +   
  scale_shape_manual(name = "Treatment & State",
                     labels = c("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"),
                     values = c(19, 19, 17, 17))

enter image description here

added 183 characters in body
Source Link
Sven Hohenstein
  • 81.4k
  • 17
  • 148
  • 172

You need to use identical name and labels values for both shape and colurcolour scale.

pd <- position_dodge(.65)
ggplot(data =data= data,aes(x= year, y = beta, colour = state1, group = group2, shape = group1group2)) +    
  geom_point(position = pd, size = 4) +
  geom_errorbar(aes(ymin = lcl, ymax = ucl), colour = "black", width = 0.5, position = pd) +
  scale_colour_huescale_colour_manual(name="Treatment & State", 
  #Legend label, use darker colors
                 labels = labels=cc("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"), 
 l=40                     values=c("blue", "red", "blue", "red")) +   
  scale_shapescale_shape_manual(name="Treatment & State",
                     labels = c("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"),
                     values=c(19, 19, 17, 17))

enter image description here

You need to use identical name and labels values for both shape and colur scale.

pd <- position_dodge(.65)
ggplot(data =data,aes(x= year, y = beta, colour = state1, group = group2, shape = group1)) +    
  geom_point(position = pd, size = 4) +
  geom_errorbar(aes(ymin = lcl, ymax = ucl),colour = "black", width = 0.5, position = pd) +
  scale_colour_hue(name="Treatment & State",  #Legend label, use darker colors
                   labels=c("Control, Non-F", "Exclosure, Flwr"), l=40) +
  scale_shape(name="Treatment & State", labels = c("Control, Non-F", "Exclosure, Flwr"))

You need to use identical name and labels values for both shape and colour scale.

pd <- position_dodge(.65)
ggplot(data = data,aes(x= year, y = beta, colour = group2, shape = group2)) +    
  geom_point(position = pd, size = 4) +
  geom_errorbar(aes(ymin = lcl, ymax = ucl), colour = "black", width = 0.5, position = pd) +
  scale_colour_manual(name="Treatment & State", 
                      labels = c("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"), 
                      values=c("blue", "red", "blue", "red")) +   
  scale_shape_manual(name="Treatment & State",
                     labels = c("Control, Non-F", "Control, Flwr", "Exclosure, Non-F", "Exclosure, Flwr"),
                     values=c(19, 19, 17, 17))

enter image description here

Post Undeleted by Sven Hohenstein
Post Deleted by Sven Hohenstein
Source Link
Sven Hohenstein
  • 81.4k
  • 17
  • 148
  • 172

You need to use identical name and labels values for both shape and colur scale.

pd <- position_dodge(.65)
ggplot(data =data,aes(x= year, y = beta, colour = state1, group = group2, shape = group1)) +    
  geom_point(position = pd, size = 4) +
  geom_errorbar(aes(ymin = lcl, ymax = ucl),colour = "black", width = 0.5, position = pd) +
  scale_colour_hue(name="Treatment & State",  #Legend label, use darker colors
                   labels=c("Control, Non-F", "Exclosure, Flwr"), l=40) +
  scale_shape(name="Treatment & State", labels = c("Control, Non-F", "Exclosure, Flwr"))