I would guess something like this:
pdf("yourplot.pdf") # or jpeg, etc.
yourplot
dev.off()
Scott
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
p3 <- grid.arrange(p1, p2, nrow=1) # p1 and p2 are plots
ggsave(file = "efecto.png", plot = p3, dpi = 400)
or the traditional way:
png(...)
grid.arrange(...)
dev.off()
Manuel Sp�nola wrote:
> Dear list members,
>
> I am trying to save a grid.arrange plot:
>
> > x11(10,6)
> > grid.arrange(p1, p2, nrow=1) # p1 and p2 are plots
> > ggsave(file = "efecto.png", dpi = 400)
> Saving 7" x 7" image
>
> But the saved plot is only one of them, not the 2 plots that I am trying
> to save in the same plot window.
>
> Any hint on how to do it?
>
> Best,
>
> Manuel
>
>
> --
> *Manuel Sp�nola, Ph.D.*
> Instituto Internacional en Conservaci�n y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspi...@una.ac.cr
> mspin...@gmail.com
> Tel�fono: (506) 2277-3598
> Fax: (506) 2237-7036
> Personal website: Lobito de r�o
> <https://sites.google.com/site/lobitoderio/>
> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
I wonder if it could be desirable to extend ggsave to a wider class of
objects. For instance, one can do the following trick,
- add a class to the compound object (Grid-based, obviously)
- define a print method
ggsave checks that the object derives from the class ggplot, and later
print()s it (print options are not implemented below),
library(ggplot2) ; library(gridExtra)
g = arrangeGrob(qplot(1:10, 1:10), tableGrob(head(iris)))
g2 = gTree(children = gList(g), cl=c("arrange", "ggplot"))
print.arrange = function(x, ...) grid.draw(x)
ggsave("test.pdf", g2)
Just a thought anyway,
baptiste
On Thu, Feb 17, 2011 at 11:36 PM, Erik Iverson <er...@ccbr.umn.edu> wrote:
> Not tested, but try:
>
> p3 <- grid.arrange(p1, p2, nrow=1) # p1 and p2 are plots
> ggsave(file = "efecto.png", plot = p3, dpi = 400)
>
> or the traditional way:
>
> png(...)
>
> grid.arrange(...)
>
> dev.off()
>
> Manuel Spínola wrote:
>>
>> Dear list members,
>>
>> I am trying to save a grid.arrange plot:
>>
>> > x11(10,6)
>> > grid.arrange(p1, p2, nrow=1) # p1 and p2 are plots
>> > ggsave(file = "efecto.png", dpi = 400)
>> Saving 7" x 7" image
>>
>> But the saved plot is only one of them, not the 2 plots that I am trying
>> to save in the same plot window.
>>
>> Any hint on how to do it?
>>
>> Best,
>>
>> Manuel
>>
>>
>> --
>> *Manuel Spínola, Ph.D.*
>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>> Universidad Nacional
>> Apartado 1350-3000
>> Heredia
>> COSTA RICA
>> mspi...@una.ac.cr
>> mspin...@gmail.com
>> Teléfono: (506) 2277-3598
>> Fax: (506) 2237-7036
>> Personal website: Lobito de río
Not tested, but try:
p3 <- grid.arrange(p1, p2, nrow=1) # p1 and p2 are plots
ggsave(file = "efecto.png", plot = p3, dpi = 400)
or the traditional way:
png(...)
grid.arrange(...)
dev.off()
Manuel Spínola wrote:
Dear list members,
I am trying to save a grid.arrange plot:
> x11(10,6)
> grid.arrange(p1, p2, nrow=1) # p1 and p2 are plots
> ggsave(file = "efecto.png", dpi = 400)
Saving 7" x 7" image
But the saved plot is only one of them, not the 2 plots that I am trying to save in the same plot window.
Any hint on how to do it?
Best,
Manuel
--
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspi...@una.ac.cr
mspin...@gmail.com
Teléfono: (506) 2277-3598
Fax: (506) 2237-7036
Personal website: Lobito de río <https://sites.google.com/site/lobitoderio/>
Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
grid.arrange() is from gridExtra not ggExtra, and yes, the output
doesn't belong to the class ggplot.
Feel free to try it out,
library(ggplot2)
source("http://gridextra.googlecode.com/svn/trunk/R/arrange.r")
g1 = rectGrob(gp=gpar(fill="grey"))
g2 = textGrob("test")
g3 = qplot(1:10, 1:10)
grid.arrange(g1,g2,g3)
g4 = arrangeGrob(g1,g2,g3, main = "testing grid.arrange()")
g5 = arrangeGrob(g1,g2), main = "testing grid.arrange()")
ggsave("test.pdf", g4)
## this fails, no ggplot present
ggsave("test2.pdf", g5)
# Error in ggsave("test2.pdf", g5) : plot should be a ggplot2 plot
baptiste
On Fri, Feb 18, 2011 at 1:52 PM, Manuel Spínola <mspin...@gmail.com> wrote:
> Thank you very much Baptiste and Dennis.
>
> Is there any function that allow me align 2 plots in a row in ggExtra?
No. grid.arrange(..., nrow=1) might be OK if you don't need the y-axes
to be exactly aligned. You could look at the code in align.plots(), it
wouldn't be too hard to do the same for horizontal layouts. (Since
Hadley has been working on a rewrite of the package, I feel lazy to
work on such ugly hacks).