ggplot2 custom legend shapes

后端 未结 1 1660
慢半拍i
慢半拍i 2020-12-03 15:29

When we have both shape and color legend in scatter plot, the shape of color legend is misleading:

foo <- data.frame(
  length=runif(10),
  height=runif(1         


        
相关标签:
1条回答
  • 2020-12-03 16:30

    It is possible to manually change the properties of the legend using guides:

    ggplot(foo, aes(x = length, y = height, color=group, shape=quality)) + 
      geom_point(size=5) + 
      guides(colour = guide_legend(override.aes = list(shape = 15)))
    

    Just play around with the shape paramater to find an appropriate shape.

    enter image description here

    0 讨论(0)
提交回复
热议问题