Hi. I would like to make a scatterplot where all of the points are evenly spaced from each other - however, they are all the same size and occupy the entire graph. For example: x = rep(c(1:10), 10) y = rep(c(10:1), each = 10) plot(x, y, pch = 0) Gives me a scatter plot with 100 square points each evenly spaced between each other. But these points don't fill up the entire space and if I try to change the 'cex' value, the points on the edges get messed up. I was wondering if there was a way to fill up the entire space (all of the edges of the little squares are touching each other) and each individual square is the same size. Any help will be greatly appreciated! -- View this message in context: http://r.789695.n4.nabble.com/How-to-generate-scatterplot-with-a-twist-tp2923805p2923805.html Sent from the R help mailing list archive at Nabble.com.
On Oct 1, 2010, at 10:41 AM, thernubblet wrote:> > Hi. I would like to make a scatterplot where all of the points are evenly > spaced from each other - however, they are all the same size and occupy the > entire graph. For example: > > x = rep(c(1:10), 10) > y = rep(c(10:1), each = 10) > plot(x, y, pch = 0) > > Gives me a scatter plot with 100 square points each evenly spaced between > each other. But these points don't fill up the entire space and if I try to > change the 'cex' value, the points on the edges get messed up. I was > wondering if there was a way to fill up the entire space (all of the edges > of the little squares are touching each other) and each individual square is > the same size. Any help will be greatly appreciated!Is this along the lines of what you might be looking for: x <- 0.5:10.5 y <- 0.5:10.5 plot(x, y, type = "n", xaxs = "i", yaxs = "i") grid(10, 10, lty = "solid", col = "black") You can get the same effect (intersecting horizontal and vertical lines) by using ?abline and setting 'h' and 'v' to the values that you require: x <- 0.5:10.5 y <- 0.5:10.5 plot(x, y, type = "n", xaxs = "i", yaxs = "i") abline(v = 0.5:10.5) abline(h = 0.5:10.5) See ?grid and also look at 'xaxs' in ?par. You can also add additional content to the existing plot by then using functions such as ?points, ?lines, ?segments, etc. HTH, Marc Schwartz
If it is important to have points rather than just create the grid, then you could do something using the my.symbols function in the TeachingDemos package. One of the examples on the help page fills the plot with hexagons, the calculations for squares should be simpler. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of thernubblet > Sent: Friday, October 01, 2010 9:41 AM > To: r-help at r-project.org > Subject: [R] How to generate scatterplot - with a twist > > > Hi. I would like to make a scatterplot where all of the points are > evenly > spaced from each other - however, they are all the same size and occupy > the > entire graph. For example: > > x = rep(c(1:10), 10) > y = rep(c(10:1), each = 10) > plot(x, y, pch = 0) > > Gives me a scatter plot with 100 square points each evenly spaced > between > each other. But these points don't fill up the entire space and if I > try to > change the 'cex' value, the points on the edges get messed up. I was > wondering if there was a way to fill up the entire space (all of the > edges > of the little squares are touching each other) and each individual > square is > the same size. Any help will be greatly appreciated! > -- > View this message in context: http://r.789695.n4.nabble.com/How-to- > generate-scatterplot-with-a-twist-tp2923805p2923805.html > Sent from the R help mailing list archive at Nabble.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.