代码之家  ›  专栏  ›  技术社区  ›  LLL

指南_legend()使图例图标变小不起作用

  •  1
  • LLL  · 技术社区  · 7 年前

    我想用 guides(colour = guide_legend(override.aes = list(size=1))) 在ggplot2()中修改图例图标大小(使其变小)。

    它不起作用;我试过换衣服 colour fill 因为这就是我要说的 aes 但这也不管用。

    任何帮助都将不胜感激!

    # Libraries  
    library(ggplot2)
    
    # Dataframe 
    df <- data.frame(location=c("all","all","south","south","north","north"),gender=c("female","male","female","male","female","male"),proportion=c(72.5,27.5,71.3,28.7,75.2,24.8))
    
    # Plot 
    p_mwe <- ggplot(df, aes(x=location,y=proportion,fill=gender)) + 
      geom_bar(position="dodge", stat="identity") + theme_classic() + coord_flip()+ 
      scale_fill_manual(values=c("gray88","gray44")) + xlab("")+ ylab("prop (%)") +labs(fill="") +
      theme(legend.position="top",legend.text = element_text(colour="black", size=10)) +  ggtitle("a) MWE plot") + guides(colour = guide_legend(override.aes = list(size=1))) 
    
    0 回复  |  直到 7 年前