Adding legend to ggplot

后端 未结 2 716
鱼传尺愫
鱼传尺愫 2021-01-27 06:23

This question is a follow-up to this post: previous post

I have 12 variables, M1, M2, ..., M12, for which I compute certain statistics

相关标签:
2条回答
  • 2021-01-27 07:03
    library(reshape2)
    df1 <- melt(df, id="model")
    
    levels = seq(0.8, 1.2, 0.05)
    
    ggplot(data=df1) + 
      geom_polygon(aes(x=model, y=value, group=variable, colour=variable), fill = NA) + 
      scale_colour_manual(values=c("a"="blue", "b"="red")) +
      coord_polar() + 
      scale_y_continuous(limits=range(levels), breaks=levels, labels=levels) +
      theme(axis.text.y = element_blank(), axis.ticks = element_blank(), axis.title.x = element_blank(), axis.title.y = element_blank())
    

    enter image description here

    0 讨论(0)
  • 2021-01-27 07:06

    You can remove the background from the legend by adding:

    + theme(legend.background=element_rect(colour=NA) 
    

    Don't forget to add an last closing parenthesis.

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