r - Vertical alignment of legend title (ggplot2) -


i trying align legend title colorbar in ggplot2. how can make title vertically aligned colorbar (instead of whole colorbar plus number)?

up result, trying various theme, element_text , guides options, whatever vertical position of title not change.

results

library(ggplot2) library(grid) theme_set(theme_bw() +   theme(panel.grid.major = element_blank(),         panel.grid.minor = element_blank(),         legend.position="bottom",         legend.text=element_text(size=14),         legend.title=element_text(size=14,hjust=-0.4),         legend.direction='horizontal',         legend.box = "vertical",         strip.background = element_rect(colour='black',fill = "white"),         plot.margin=unit(0.05*c(1,1,1,1),'npc'),         plot.title=element_text(size=18),         axis.title=element_text(size=18,vjust=0.2),         axis.text=element_text(size=14),         strip.text=element_text(size=14)))  ggplot(diamonds,aes(x,y,color=z))+   geom_point()+   scale_colour_gradient2('time [min]',                          low='lightgray',                          mid='red3',                          high='red4',                          midpoint=15) 

you can change vertical possition of legend title argument title.vjust= inside guide_colourbar= of function guides().

 + guides(color=guide_colourbar(title.vjust=1)) 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -