tag:blogger.com,1999:blog-6232819486261696035.post6595183349233798673..comments2023-09-25T09:01:44.323-05:00Comments on Getting Genetics Done: Arrange multiple ggplot2 plots in the same image windowStephen Turnerhttp://www.blogger.com/profile/06656711316726116187noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-6232819486261696035.post-86723168928660553102014-09-03T20:34:26.018-05:002014-09-03T20:34:26.018-05:00Perfect - Thank you!Perfect - Thank you!Anonymoushttps://www.blogger.com/profile/18107418450379709279noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-51988025498943557732014-03-12T12:22:47.533-05:002014-03-12T12:22:47.533-05:00I am wondering the same thing here. I see that yo...I am wondering the same thing here. I see that you cannot simply change <br /><br />theme(plot.margin = ...)<br /><br />is the margin something that is a constant when using this function or is it an function of the plot size? Also how can we reduce this and increase size of plots?<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-24583670470085712032014-01-02T20:28:52.495-06:002014-01-02T20:28:52.495-06:00Thanks Steven for the code. It´s has been very use...Thanks Steven for the code. It´s has been very useful !!<br />One question. I have a plot of 5x3 and I would like to reduce the blank space between plots. Is it possible?<br />Thanks<br />Juan CarlosAnonymoushttps://www.blogger.com/profile/11941405535590175873noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-81121139791542649632012-11-21T07:34:23.212-06:002012-11-21T07:34:23.212-06:00Thanks for sharing. I modified this code above yea...Thanks for sharing. I modified this code above years ago from something I found in a mailing list or forum. I think eventually this functionality became part of the gridextra package. Stephen Turnerhttps://www.blogger.com/profile/06656711316726116187noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-73005740737884716812012-11-20T17:34:31.179-06:002012-11-20T17:34:31.179-06:00Thanks Steven! My google searches seem to end up o...Thanks Steven! My google searches seem to end up on your blog fairly often with helpful results. I also found this package (http://code.google.com/p/gridextra/) which may be useful as well.Kevinhttps://www.blogger.com/profile/18133621252748596655noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-79105540405568705412012-09-14T16:35:16.191-05:002012-09-14T16:35:16.191-05:00Apologies - I updated the code (and renamed the fu...Apologies - I updated the code (and renamed the function to arrange_ggplot2). The problem is newer versions of ggplot2 don't automatically load the grid package, so you have to load it manually. I put this in as the first line of code. Give it a shot now.Stephen Turnerhttps://www.blogger.com/profile/06656711316726116187noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-48304277988004063362012-09-14T14:56:07.443-05:002012-09-14T14:56:07.443-05:00i put your code from above in R and run it and tha...i put your code from above in R and run it and than told him to arrange my plots, but i always get the error message <br /><br />couldn't find function "grid.newpage" <br /><br />any idea what i could do differently?Anonymoushttps://www.blogger.com/profile/02720073800252336090noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-46927836466560708922012-06-03T09:07:51.568-05:002012-06-03T09:07:51.568-05:00how do you control the space between the plots whe...how do you control the space between the plots when using "arrange function"?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-58404876329384504232011-06-08T11:23:59.237-05:002011-06-08T11:23:59.237-05:00Thank you Stephen Turner. It has been great use yo...Thank you Stephen Turner. It has been great use your code. Thanks.Freddy Lopezhttps://www.blogger.com/profile/04560516889321267412noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-50788897150129537482011-03-24T09:39:15.257-05:002011-03-24T09:39:15.257-05:00Great trick, thanks. How to go about having two pl...Great trick, thanks. How to go about having two plots share the same x-axis?Unknownhttps://www.blogger.com/profile/17816740804974326735noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-90350348907802335842010-08-26T16:48:15.740-05:002010-08-26T16:48:15.740-05:00note that this function is included in the gridExt...note that this function is included in the gridExtra package, with the name grid.arrange() and a few more options.bapthttps://www.blogger.com/profile/13871455736213023130noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-50520345304414825712010-08-26T16:46:13.597-05:002010-08-26T16:46:13.597-05:00This comment has been removed by the author.bapthttps://www.blogger.com/profile/13871455736213023130noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-23222743482241631932010-06-28T15:11:57.147-05:002010-06-28T15:11:57.147-05:00Hey guys, can you slap a license on your code? (BS...Hey guys, can you slap a license on your code? (BSD would be highly appreciated)syrnickhttps://www.blogger.com/profile/06121834075298789289noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-12137674491576813602010-05-21T12:26:47.791-05:002010-05-21T12:26:47.791-05:00Hi,
I get the following error when I do this.
Erro...Hi,<br />I get the following error when I do this.<br />Error: attempt to apply non-function<br /><br />whats that about?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-29656922019409273872010-05-07T12:57:12.419-05:002010-05-07T12:57:12.419-05:00to save plots to file
pdf("your_file.pdf&quo...to save plots to file<br /><br />pdf("your_file.pdf",width = 11, height = 8)<br />arrange(plot1,plot2,plot3,plot4,ncol=2)<br />dev.off()Discrete Vortexhttps://www.blogger.com/profile/01461063434833313259noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-67043279250830751762010-04-08T03:26:29.477-05:002010-04-08T03:26:29.477-05:00Jennie,
I haven't had success with this eithe...Jennie,<br /><br />I haven't had success with this either. Just use the GUI to save the image as PNG or PDF. I'll post a solution if I find one. <br /><br />StephenStephen Turnerhttps://www.blogger.com/profile/06656711316726116187noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-74637963814946826262010-04-08T00:42:52.037-05:002010-04-08T00:42:52.037-05:00Great bit of code... But.. is there a way to outpu...Great bit of code... But.. is there a way to output to a file? <br /><br />I've tried:-<br />tmp<-arrange(mh3,mh4,mh1,mh2,ncol=1)<br />ggsave(file="all.png",tmp)<br /><br />Thanks in advanceJennienoreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-17800575701202892752010-04-07T14:43:28.580-05:002010-04-07T14:43:28.580-05:00woohoo! works great! thankswoohoo! works great! thanksDavid Lhttps://www.blogger.com/profile/00493902406584308322noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-6183541918632668602010-04-01T05:23:33.691-05:002010-04-01T05:23:33.691-05:00Dan, the arrange function is not included with ggp...Dan, the arrange function is not included with ggplot2. You have to copy and paste the code in the first box above to get it to work.Stephen Turnerhttps://www.blogger.com/profile/06656711316726116187noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-90377882581578899302010-03-31T21:41:40.291-05:002010-03-31T21:41:40.291-05:00I started learning ggplot2 a couple weeks ago, so ...I started learning ggplot2 a couple weeks ago, so maybe I'm missing something. After I load the library(ggplot2), arrange() isn't showing up as a function. I tried loading library(ggplot), to see if it was in there, but still no luck.<br /><br />Any idea? ... I've been looking for this solution, but the no-arrange() is getting in the way.Danhttp://www.booklamp.orgnoreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-53328116055961171122010-03-30T23:48:45.131-05:002010-03-30T23:48:45.131-05:00Great!! I was looking for something like this just...Great!! I was looking for something like this just today!William Doanehttp://drdoane.comnoreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-54715978137728878702010-03-16T15:46:52.597-05:002010-03-16T15:46:52.597-05:00Great tip! I've been struggling with this aspe...Great tip! I've been struggling with this aspect of ggplot2 for a while.Unknownhttps://www.blogger.com/profile/03062012616769768445noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-61154621066096654542010-03-09T14:12:10.866-06:002010-03-09T14:12:10.866-06:00Also, check out imagemagick. It's a cross plat...Also, check out <a href="http://www.imagemagick.org/script/index.php" rel="nofollow">imagemagick</a>. It's a cross platform opensource image manipulation tool. It's really handy for stitching multiple images together. But the montage binary in your path, then call:<br /><br />montage image1.png image2.png -geometry -0-0 -tile 1x composite.png<br /><br />to stitch image1 and image2 together in a single column. Ideally all your images will be the same size. You can do this with lots of images using wildcards.Stephen Turnerhttps://www.blogger.com/profile/06656711316726116187noreply@blogger.comtag:blogger.com,1999:blog-6232819486261696035.post-6198831710511980192010-03-03T14:25:34.703-06:002010-03-03T14:25:34.703-06:00wow that was fast :)wow that was fast :)Munawar Cheemanoreply@blogger.com