Hello, What would you recommend for producing publication-quality plots with R? Built-in graphics, trellis, ggplot2, or something else? Basic requirements: - I need to draw line-, box-, density-plots, bar-charts and histograms - error bars on bar- and box-plots - easy tiling of multiple plots on a single "page" Basic R plotting with mfrow and mfcol parameters is not satisfactory because a lot of space is lost on duplicated labels in margins. (In fact, I have not been able to figure out how to generate a plot that looks nicely when included in a latex document.. short of generating it on a 4x larger area, and including it scaled down by 50%.. but that's a separate issue) Lattice demos look impressive, but it seems that one must write a lot of custom functions to get what one wants -- so the learning curve is rather steep whenever one wants anything not provided out-of-the box (e.g. multiple line plots in a single figure, each with its own error bars). Is situation anything better with ggplot2? It seems rather easy to get e.g. line plots with error bars, provided that one feeds the data to some modeling/regression function and passes the result over for plotting.. but what if I have generated my own error bar data? This is almost trivial to accomplish with built-in plot functions (lines function), but that doesn't play nicely with composing plots.. Is there something that provides the simplicity and straightforwardness[1] of built-in plot functions, along with the power of lattice arrangement of plots? Experience stories are also welcome. [1] plot() takes simple vectors of x,y coordinates. I had to reverse-engineer lattice examples to figure out in what format I should present my data to it. Astounding that such elementary thing is not better explained.
> Is situation anything better with ggplot2? ?It seems rather easy to get e.g. > line plots with error bars, provided that one feeds the data to some > modeling/regression function and passes the result over for plotting.. but what > if I have generated my own error bar data? ?This is almost trivial to > accomplish with built-in plot functions (lines function), but that doesn't play > nicely with composing plots..It should be trivial with ggplot2 too, but it's hard to provide concrete advice without a concrete problem. Hadley -- http://had.co.nz/
On Fri, May 1, 2009 at 1:55 PM, Zeljko Vrba <zvrba at ifi.uio.no> wrote:> Hello, > > What would you recommend for producing publication-quality plots with R? > Built-in graphics, trellis, ggplot2, or something else? > > Basic requirements: > > - I need to draw line-, box-, density-plots, bar-charts and histograms > - error bars on bar- and box-plots > - easy tiling of multiple plots on a single "page" > > Basic R plotting with mfrow and mfcol parameters is not satisfactory because a > lot of space is lost on duplicated labels in margins. (In fact, I have not been > able to figure out how to generate a plot that looks nicely when included in a > latex document.. short of generating it on a 4x larger area, and including it > scaled down by 50%.. but that's a separate issue)Try using par(mar = ...) opar <- par(mfrow = c(2, 2)) par(mar = c(0, 3, 3, 0)) plot(0, xaxt = "n", xlab = "") par(mar = c(0, 0, 3, 3)) plot(0, xaxt = "n", yaxt = "n", ylab = "", xlab = "") par(mar = c(3, 3, 0, 0)) plot(0) par(mar = c(3, 0, 0, 3)) plot(0, yaxt = "n", ylab = "") par(opar) plot.zoo in the zoo package is another example of this.