I have a script that creates a qplot that is then saved as a .png file which works fine on Windows. But I also work on Linux servers via Putty and would like to be able to create and save my plots to my working directory. Is there a way I can ggsave my qplot without utilizing X11 in Linux? I don't need to view the plot in Linux, I just want the plot created and immediately saved to my working directory. I get this error: Error in grDevices::png(..., width = width, height = height, res = dpi, : X11 is not available -- View this message in context: http://n4.nabble.com/ggsave-in-Linux-tp1567860p1567860.html Sent from the R help mailing list archive at Nabble.com.
On Wed, Feb 24, 2010 at 1:28 PM, Ryan Garner <ryan.steven.garner@gmail.com>wrote:> > I have a script that creates a qplot that is then saved as a .png file > which > works fine on Windows. But I also work on Linux servers via Putty and would > like to be able to create and save my plots to my working directory. Is > there a way I can ggsave my qplot without utilizing X11 in Linux? I don't > need to view the plot in Linux, I just want the plot created and > immediately > saved to my working directory. > > I get this error: > Error in grDevices::png(..., width = width, height = height, res = dpi, : > X11 is not available > >ggsave("flie.png", my_ggplot_object) is basically equivalent to: png("file.png") print(my_ggplot_object) dev.off() but it seems that the default png device isn't working for you so perhaps you should try using another device? cairoDevice seems to support png images, i.e.: library("cairoDevice") Cairo_png("file.png") print(my_ggplot_object) dev.off() - Trevor [[alternative HTML version deleted]]
See below. On Wed, Feb 24, 2010 at 1:28 PM, Ryan Garner <ryan.steven.garner at gmail.com> wrote:> > I have a script that creates a qplot that is then saved as a .png file which > works fine on Windows. But I also work on Linux servers via Putty and would > like to be able to create and save my plots to my working directory. Is > there a way I can ggsave my qplot without utilizing X11 in Linux? I don't > need to view the plot in Linux, I just want the plot created and immediately > saved to my working directory. > > I get this error: > Error in grDevices::png(..., width = width, height = height, res = dpi, ?: > ?X11 is not availableYou get this error when you do what? I'm guessing you are trying to display the graphic, which of course won't work without a windowing system. Try like this: library(ggplot2) data(diamonds) temp <- qplot(cut, color, data=diamonds) ggsave(temp, file = "test.pdf")> > -- > View this message in context: http://n4.nabble.com/ggsave-in-Linux-tp1567860p1567860.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org
> library(ggplot2) > data(diamonds) > temp <- qplot(cut, color, data=diamonds) > ggsave(temp, file = "test.png")Saving 7" x 7" image Error in grDevices::png(..., width = width, height = height, res = dpi, : X11 is not available -- View this message in context: http://n4.nabble.com/ggsave-in-Linux-tp1567860p1567986.html Sent from the R help mailing list archive at Nabble.com.