Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-29 Thread Ulrik Stervbo via R-help
Then this should work: ``` library(ggplot2) library(cowplot) p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() p2 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width * 1000)) + geom_point() plot_grid(p1, p2, ncol = 1, align = "hv", rel_heights = c(2, 1), axis = "t

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-28 Thread H
On 07/28/2020 12:35 PM, Ulrik Stervbo wrote: > Would this work: > > ``` > library(ggplot2) > library(cowplot) > > p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() > p2 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width * 1000)) + > geom_point() > > plot_grid(p1, p2, nco

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-28 Thread Ulrik Stervbo via R-help
Would this work: ``` library(ggplot2) library(cowplot) p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() p2 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width * 1000)) + geom_point() plot_grid(p1, p2, ncol = 1, align = "hv", rel_heights = c(2, 1)) ``` Best, Ulrik

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-26 Thread H
On 07/25/2020 03:05 PM, H wrote: > On 07/25/2020 03:01 PM, Rui Barradas wrote: >> Hello, >> >> OK, now it's reproducible, thanks. >> align = "hv" works like I had suggested. >> >> The full code is now >> >> library(ggplot2) >> library(cowplot) >> >> s <- ggplot(data = subset(iris, Species == 'virgi

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread H
On 07/25/2020 03:01 PM, Rui Barradas wrote: > Hello, > > OK, now it's reproducible, thanks. > align = "hv" works like I had suggested. > > The full code is now > > library(ggplot2) > library(cowplot) > > s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, > Sepal.Width)) + g

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread Rui Barradas
Hello, OK, now it's reproducible, thanks. align = "hv" works like I had suggested. The full code is now library(ggplot2) library(cowplot) s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, Sepal.Width)) + geom_point() v <- ggplot(data = subset(iris, Species == 'setosa'

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread H
On 07/25/2020 12:36 PM, Rui Barradas wrote: > Hello, > > Inline. > > Às 16:54 de 25/07/2020, H escreveu: >> On 07/24/2020 05:56 PM, Rui Barradas wrote: >>> Hello, >>> >>> I've just tried it. >>> >>> library(ggplot2) >>> #library(grid) >>> library(cowplot) >>> >>> s <- ggplot(data = subset(iris, Spe

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread Rui Barradas
Hello, Inline. Às 16:54 de 25/07/2020, H escreveu: On 07/24/2020 05:56 PM, Rui Barradas wrote: Hello, I've just tried it. library(ggplot2) #library(grid) library(cowplot) s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, Sepal.Width)) + geom_point() v <- ggplot(dat

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread H
On 07/24/2020 05:56 PM, Rui Barradas wrote: > Hello, > > I've just tried it. > > library(ggplot2) > #library(grid) > library(cowplot) > > s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, > Sepal.Width)) + geom_point() > v <- ggplot(data = subset(iris, Species == 'setosa')

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread Rui Barradas
Hello, I've just tried it. library(ggplot2) #library(grid) library(cowplot) s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, Sepal.Width)) + geom_point() v <- ggplot(data = subset(iris, Species == 'setosa'), aes(Sepal.Length, Sepal.Width)) + geom_point() #g2 <- ggp

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread Bert Gunter
?grid.frame, etc. should be straightforward for this I would think. But of course you have to resort to the underlying grid framework rather than the ggplot2 interface. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Be

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread H
On 07/24/2020 02:50 PM, H wrote: > On 07/24/2020 02:03 PM, Jeff Newmiller wrote: >> The set of people interested in helping when you supply a minimal >> reproducible example is rather larger than the set of people willing to read >> the documentation for you (hint) and guess what aspect of alignm

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread Felipe Carrillo via R-help
What about cowplot? https://cran.r-project.org/web/packages/cowplot/vignettes/introduction.html On Friday, July 24, 2020, 11:51:17 AM PDT, H wrote: On 07/24/2020 02:03 PM, Jeff Newmiller wrote: > The set of people interested in helping when you supply a minimal > reproducible example i

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread H
On 07/24/2020 02:03 PM, Jeff Newmiller wrote: > The set of people interested in helping when you supply a minimal > reproducible example is rather larger than the set of people willing to read > the documentation for you (hint) and guess what aspect of alignment you are > having trouble with. >

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread Jeff Newmiller
The set of people interested in helping when you supply a minimal reproducible example is rather larger than the set of people willing to read the documentation for you (hint) and guess what aspect of alignment you are having trouble with. On July 24, 2020 10:46:57 AM PDT, H wrote: >On 07/24/2

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread H
On 07/24/2020 01:14 PM, John Kane wrote: > 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. > > Sigh, we know the code works but we do not know what the plots are   and w

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread John Kane
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. 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

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread H
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 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.

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread H
On 07/24/2020 10:16 AM, John Kane wrote: > We reallly need to see more code (a minimum working example and some data. > > For some suggestions on how to do this see > >  http://adv-r.had.co.nz/Reproducibility.html > > http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-exa

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread John Kane
We reallly need to see more code (a minimum working example and some data. For some suggestions on how to do this see http://adv-r.had.co.nz/Reproducibility.html http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example On Fri, 24 Jul 2020 at 01:16, H wrote: > I a

[R] Arranging ggplot2 objects with ggplotGrob()

2020-07-23 Thread H
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 settin