[R] How can I make the legend in ggplot2 the same height as my plot?

Robert Baer rbaer at atsu.edu
Thu Jul 6 16:43:49 CEST 2017


Don't know what your data looks like, but you might  try:

p <-  Scenario1+guides(fill = guide_colorbar(bar width = 1.5, barheight 
= unit(10, "mm")))

print(p)


On 7/5/2017 5:13 PM, Kristi Glover wrote:
> Hi R Users,
>
> I tried to increase the legend height in ggplot2, but it did not respond at all using the follwoing code. Do you have any suggestions for me?
>
>
>
> dat<-data.frame(temperature)
>
> P1<-ggplot(dat, aes(X, Y))
>
> Scenario1<-P1+geom_point(aes(colour = value), size = 1)+ theme_bw()+ theme(axis.text.x = element_blank(),axis.text.y = element_blank())
>
> Scenario1<-Scenario1+facet_wrap(~variable, ncol=2)+scale_color_gradientn(colours = rainbow(48))
>
> Scenario1+guides(fill = guide_colorbar(bar width = 1.5, barheight = unit(10, "mm")))
>
>
> Thanks,
>
> KG
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list