ggplot2: Making changes to symbols in the legend

前端 未结 1 1615
栀梦
栀梦 2021-01-06 14:28

I\'m having a problem making the symbols in the legend of my plot match those in the plot itself.

Suppose the data has four columns like this

data         


        
相关标签:
1条回答
  • 2021-01-06 15:01

    Now that I'm sure it's what you want:

    library(scales)
    ggplot(data, aes(x = x, y = y)) +
              geom_point(aes(size = Rank, shape = Quantified)) +
              scale_shape_manual("Quantified", labels = c("Yes", "No"), values = c(1, 4)) + 
              guides(size = guide_legend(override.aes = list(shape = 1)))
    

    enter image description here

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