par(mfrow=c(3,4)) problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

par(mfrow=c(3,4)) problem

greg holly
Hi all;

I need to put 12 different plot2 into the same matrix. So my array for the
matrix will be par(mfrow=c(3,4)).  I am running ggplot2 to produce my 12
plots. For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix.

my basic R codes for each plot is
par(mfrow=c(3,4))
library(ggplot2)
p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight,
color=Showing_rate)) +
.
.

Best regards,

Greg

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: par(mfrow=c(3,4)) problem

Alex Zarebski
You might find the patchwork library helpful (plot_layout function)

https://github.com/thomasp85/patchwork

I'm not sure if it's on CRAN but you can devtools::github_install it.

Cheers,
Alex

On Wed, May 30, 2018 at 6:42 PM, greg holly <[hidden email]> wrote:

> Hi all;
>
> I need to put 12 different plot2 into the same matrix. So my array for the
> matrix will be par(mfrow=c(3,4)).  I am running ggplot2 to produce my 12
> plots. For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix.
>
> my basic R codes for each plot is
> par(mfrow=c(3,4))
> library(ggplot2)
> p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight,
> color=Showing_rate)) +
> .
> .
>
> Best regards,
>
> Greg
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: par(mfrow=c(3,4)) problem

Sarah Goslee
In reply to this post by greg holly
Hi,

You're mixing base plot and ggplot2 grid graphics, which as you've
discovered doesn't work.

Here's av strategy that does:
https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html

This vignette has a good overview, well as info specific to that package.

Sarah


On Wed, May 30, 2018 at 4:43 AM greg holly <[hidden email]> wrote:

> Hi all;
>
> I need to put 12 different plot2 into the same matrix. So my array for the
> matrix will be par(mfrow=c(3,4)).  I am running ggplot2 to produce my 12
> plots. For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix.
>
> my basic R codes for each plot is
> par(mfrow=c(3,4))
> library(ggplot2)
> p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight,
> color=Showing_rate)) +
> .
> .
>
> Best regards,
>
> Greg
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>
--
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: par(mfrow=c(3,4)) problem

PIKAL Petr
In reply to this post by greg holly
Hi

You combine basic graphic (par) and grid graphic (ggplot), which is possible but not strightforward.
You could check it e.g.
par(mfrow=c(1,2))
plot(1,1)
plot(1,2)
library(ggplot2)
d <- ggplot(diamonds, aes(carat, price))
d + geom_point(alpha = 1/10)
d + geom_point(alpha = 1/20)

In grid graphic you could use ?facet_grid to get multiple plots on one page.

Or you could use Google and find

www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/
http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/81-ggplot2-easy-way-to-mix-multiple-graphs-on-the-same-page/

Cheers
Petr

Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohlášení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/

> -----Original Message-----
> From: R-help [mailto:[hidden email]] On Behalf Of greg holly
> Sent: Wednesday, May 30, 2018 10:43 AM
> To: r-help mailing list <[hidden email]>
> Subject: [R] par(mfrow=c(3,4)) problem
>
> Hi all;
>
> I need to put 12 different plot2 into the same matrix. So my array for the
> matrix will be par(mfrow=c(3,4)).  I am running ggplot2 to produce my 12 plots.
> For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix.
>
> my basic R codes for each plot is
> par(mfrow=c(3,4))
> library(ggplot2)
> p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight,
> color=Showing_rate)) +
> .
> .
>
> Best regards,
>
> Greg
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

________________________________
Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system.
If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: par(mfrow=c(3,4)) problem

Martin Maechler
In reply to this post by Sarah Goslee
>>>>> Sarah Goslee
>>>>>     on Wed, 30 May 2018 05:03:56 -0400 writes:

    > Hi,
    > You're mixing base plot and ggplot2 grid graphics, which as you've
    > discovered doesn't work.

    > Here's av strategy that does:
    > https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html

    > This vignette has a good overview, well as info specific to that package.

    > Sarah

A very nice vignette indeed!  Didn't know about these.
Thank you, Sarah, and thanks to the author, Baptiste Auguie !

Martin

    > On Wed, May 30, 2018 at 4:43 AM greg holly <[hidden email]> wrote:

    >> Hi all;
    >>
    >> I need to put 12 different plot2 into the same matrix. So my array for the
    >> matrix will be par(mfrow=c(3,4)).  I am running ggplot2 to produce my 12
    >> plots. For some reason, par(mfrow=c(3,4)) did not turn out 3*4 matrix.
    >>
    >> my basic R codes for each plot is
    >> par(mfrow=c(3,4))
    >> library(ggplot2)
    >> p <- ggplot(a, aes(x=Genotypes, y=Plant_hight, size=Plant_hight,
    >> color=Showing_rate)) +
    >> .
    >> .
    >>
    >> Best regards,
    >>
    >> Greg
    >>
    >> [[alternative HTML version deleted]]
    >>
    >> ______________________________________________
    >> [hidden email] 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.
    >>
    > --
    > Sarah Goslee
    > http://www.stringpage.com
    > http://www.sarahgoslee.com
    > http://www.functionaldiversity.org

    > [[alternative HTML version deleted]]

    > ______________________________________________
    > [hidden email] 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.

______________________________________________
[hidden email] 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.