[R] Arranging ggplot2 objects with ggplotGrob()

John Kane jrkr|de@u @end|ng |rom gm@||@com
Fri Jul 24 19:14:30 CEST 2020


<i>Well, I am not looking for help debugging my code but for information to
better understand arranging plots vertically. The code above aligns them
horizontally as expected.</i>

Sigh, we know the code works but we do not know what the plots are   and we
cannot play around with them to see if we can help you if we have nothing
to work with.

On Fri, 24 Jul 2020 at 12:12, H <agents using meddatainc.com> wrote:

> On 07/24/2020 05:29 AM, Erich Subscriptions wrote:
> > Hav a look at the packages cowplot and patchwork
> >
> >> On 24.07.2020, at 02:36, H <agents using meddatainc.com> wrote:
> >>
> >> I am trying to arrange two plots vertically, ie plot 2 below plot 1,
> where I want the plots to align columnwise but have a height ratio of eg
> 3:1.
> >>
> >> My attempts so far after consulting various webpages is that the
> following code aligns them columnwise correctly but I have, so far, failed
> in setting the relative heights...
> >>
> >> g2<-ggplotGrob(s)
> >> g3<-ggplotGrob(v)
> >> g<-rbind(g2, g3, size = "first")
> >> g$widths<-unit.pmax(g2$widths, g3$widths)
> >>
> >> what would the appropriate statement for the relative heights to add
> here be?
> >>
> >> grid.newpage()
> >> grid.draw(g)
> >>
> >> Thank you!
> >>
> >> ______________________________________________
> >> R-help using 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.
>
> So this is not possible without using one of those two packages? I got the
> impression I should be able to use grid.arrange to do so but was not able
> to get it to work without disturbing the width alignment above...
>
> ______________________________________________
> R-help using 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.
>


-- 
John Kane
Kingston ON Canada

	[[alternative HTML version deleted]]



More information about the R-help mailing list