guide_legend()使图例图标变小而不起作用

时间:2018-11-14 13:56:18

标签: r ggplot2

我正在尝试使用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 个答案:

没有答案