[R] pie graphs in log scale axis

Ortiz, John OrtizJ at si.edu
Mon Oct 28 14:40:51 CET 2013

Dear list users,

I'm doing a plot integrating Grid output with Base Graphics output  (gridBase, Murrell 2012).

My goal is to produce a xy plot where each point is represented by a pie.  I could get it using the attach code,
but now I want to change the X axis to log scale.

when I introduce the log="x" parameter in the line:

plot(x, y, xlim=c(0.1, 1.2), log="x", ylim=c(0.1, 1.2), type="n")

I get this warning!

vps <- baseViewports()
Warning message:
In baseViewports() : viewport scales NOT set to user coordinates

This is the code to produce it without introduce log scale yet:

x <- c(0.88, 1.00, 0.67, 0.34)
y <- c(0.87, 0.43, 0.24, 0.94)
z <- matrix(runif(4*2), ncol=2)

oldpar <- par(no.readonly=TRUE)

plot(x, y, xlim=c(0.1, 1.2), ylim=c(0.1, 1.2), type="n")

vps <- baseViewports()
pushViewport(vps$inner, vps$figure, vps$plot)

for (i in 1:4) {
 pushViewport(viewport(x=unit(x[i], "native"),
 y=unit(y[i], "native"),
 par(plt=gridPLT(), new=TRUE)
 pie(z[i,], radius=1, labels=rep("", 2))


Thanks by some advice!!


John Ortiz

Smithsonian Tropical Research Institute Panama

More information about the R-help mailing list