在ggplot2中将colorbar的标题设置为白色

时间:2016-10-12 17:28:14

标签: r ggplot2

如果我有一个scale_fill_coninuous(name='Servings'),我希望它是白色的。如何为此设置主题参数?在上面的代码中添加color ='white'不起作用。这是我的ggplot。

 ggplot() + 
  geom_map(data = map.world,map = map.world,colour='white',size=.25, aes(
    map_id = region,
    x=long,
    y=lat,
    fill=beer_servings
  )) + 
  theme(panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(),
        plot.background = element_rect(fill = "black"),
        panel.background = element_rect(fill = "black"),
        legend.background = element_rect(fill='black', 
                                         size=0.5, linetype="solid"),
        legend.text = element_text(colour = 'white'),
        legend.position = 'bottom'
        )+
  scale_fill_continuous(name = "Servings Of Beer \nPer Person, 2010")+
  #guides(fill = guide_legend(
    #title.theme = element_text(size=10, colour = "white",angle = 0)))+
  coord_quickmap()

1 个答案:

答案 0 :(得分:0)

抱歉,发现了这个。

theme(legend.title =
    element_text(face = "italic", size = 12, angle = 45, color = "grey70") )