Dear R People: Short of doing a series of ablines, is there a way to produce "graph paper" in R please? Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodgess at gmail.com
You could draw a grid with grid, using grid.grill, library(grid) pdf("grid.pdf", width=21/2.54,height=29.7/2.54) grid.grill(h = unit(seq(0, 297, by=1), "mm"), v = unit(seq(0, 210, by=1), "mm"), gp=gpar(col="grey",lwd=0.1)) grid.grill(h = unit(seq(0, 297, by=5), "mm"), v = unit(seq(0, 210, by=5), "mm"), gp=gpar(col="grey20",lwd=0.2)) grid.grill(h = unit(seq(0, 29.7, by=1), "cm"), v = unit(seq(0, 21, by=1), "cm"), gp=gpar(col="black",lwd=1)) dev.off() HTH, b. On 19 January 2012 14:18, Erin Hodgess <erinm.hodgess at gmail.com> wrote:> Dear R People: > > Short of doing a series of ablines, is there a way to produce "graph > paper" in R please? > > Thanks, > Erin > > > -- > Erin Hodgess > Associate Professor > Department of Computer and Mathematical Sciences > University of Houston - Downtown > mailto: erinm.hodgess at gmail.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.
Erin Hodgess <erinm.hodgess <at> gmail.com> writes:> Short of doing a series of ablines, is there a way to produce "graph > paper" in R please?How about ?grid ...
Erin Hodgess-2 wrote> > Dear R People: > > Short of doing a series of ablines, is there a way to produce "graph > paper" in R please? > > Thanks, > Erin > > > -- > Erin Hodgess > Associate Professor > Department of Computer and Mathematical Sciences > University of Houston - Downtown > mailto: erinm.hodgess@ > > ______________________________________________ > R-help@ 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. >How about ... x = rnorm(100) y = rnorm(100) plot(x,y) grid() HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/graph-paper-look-tp4308827p4308906.html Sent from the R help mailing list archive at Nabble.com.
You could look at grid(), but the Note in the documentation suggests "If more fine tuning is required, use abline(h = ., v = .) directly." Also grid() uses the default axis positions so if you specify details of the axis with xlim, ylim, etc the grid does not line up on the tickmarks. Using abline is pretty simple. Use xpd=TRUE to get abline to draw outside the plot region. oldpar <- par(xpd=TRUE) plot(c(0,1),c(0,1), axes=FALSE, pch=NA, xlab="", ylab="") abline(v=seq(-1, 2, .1), h=seq(-1, 2, .1), lty=3, col="gray") abline(v=seq(-1, 2, .5), h=seq(-1, 2, .5), lty=1, col="gray") par(oldpar) ---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Erin Hodgess Sent: Wednesday, January 18, 2012 7:19 PM To: r-help at r-project.org Subject: [R] graph paper look Dear R People: Short of doing a series of ablines, is there a way to produce "graph paper" in R please? Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodgess at gmail.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.
In addition to the recommendations to use the grid function, you could just do: par(tck=1) before calling the plotting functions. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Erin Hodgess Sent: Wednesday, January 18, 2012 6:19 PM To: r-help at r-project.org Subject: [R] graph paper look Dear R People: Short of doing a series of ablines, is there a way to produce "graph paper" in R please? Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodgess at gmail.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.