michael westphal
2010-May-16 01:31 UTC
[R] problem with making multiple plots (geom_pointrange) in a loop (ggplot2)
Hello: I am using R 2.10.1 I am trying to make multiple scatter plots with ggplot2, using a for loop to select only certain entries in a dataframe. Here is my code: for(i in 1:length(ganges_subbasin[,1] )){ subbasin_select <- as.character(ganges_subbasin[i, 2]) #print(subbasin_select) subbasin_select <- as.character(ganges_subbasin[i, 2]) p <- ggplot(ganges_subbasin_a2pre_sort ,aes(x = Month, y = med, ymin = min, ymax = max, subset = CATCHMENT_ == subbasin_select)) + ylab("Precipitation (mm)\n") + opts(title = paste("Projected Precipitation 2030 - 2049 (Sub-Basin ", subbasin_select, ")\n", sep "")) + scale_colour_grey() p + geom_pointrange(linetype = 2, colour = "navyblue") + opts(axis.text.x = theme_text(colour = "black")) + opts(axis.text.y theme_text(colour = "black")) + opts(axis.ticks theme_segment(colour = "white")) ggsave(paste(subbasin_select,"2100.jpeg", sep = " ")) } dev.off() Unfortunately, I get this error: "Saving 6.95" x 6.94" image Error in grDevices::jpeg(..., width = width, height = height, res dpi, : unable to start device In addition: Warning messages: 1: In grDevices::jpeg(..., width = width, height = height, res dpi, : Unable to allocate bitmap 2: In grDevices::jpeg(..., width = width, height = height, res dpi, : opening device failed>" Any suggestions? Thank you. Michael [[alternative HTML version deleted]]
baptiste auguie
2010-May-16 09:45 UTC
[R] problem with making multiple plots (geom_pointrange) in a loop (ggplot2)
Hi, On 16 May 2010 03:31, michael westphal <mi_westphal at yahoo.com> wrote: [ snipped ]> Any suggestions? >i'd suggest you - read the posting guide - upgrade your R to the latest version - don't post to two mailing lists - make your example minimal, self-contained, reproducible - show the result of sessionInfo() HTH, baptiste> > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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. >