I am using R with cygwin and trying to build some basic graphics. Here is a simple example from one of Paul Murrell's articles:
library(grid) x <- rnorm(50) y <- x + rnorm(50, 1, 2) rx <- range(x) dx <- diff(rx) ry <- range(y) dy <- diff(ry) max <- max(rx, ry) min <- min(rx, ry) r <- c(min(rx, ry), max(rx, ry)) d <- diff(r) scale <- r + c(-1, 1) * d * 0.05 extscale <- c(min(scale), max(scale) + diff(scale) * 1/3) lay <- grid.layout(2, 2, widths = unit(c(3, 1), "inches"), heights = unit(c(1, 3), "inches")) vp1 <- viewport(w = unit(4, "inches"), h = unit(4, "inches"), layout = lay, xscale = extscale, yscale = extscale) grid.newpage() pushViewport(vp1) grid.rect() grid.xaxis() grid.text("Test", y = unit(-3, "lines")) grid.yaxis() grid.text("Retest", x = unit(-3, "lines"), rot = 90) vp2 <- viewport(layout.pos.row = 2, layout.pos.col = 1, xscale = scale, yscale = scale) pushViewport(vp2) grid.lines() grid.points(x, y, gp = gpar(col = "blue"))
It's good. If, however, I add the following line to the program:
grid.lines(x, y, gp = gpar(col = "red"))
Lines are everywhere. I expected the lines to connect the dots in order. I had a similar problem with some code that I wrote, but there the lines are good, but the dots do not.
Would thank for any help. Thanks.