[R] ggplot questions

From: Thompson, David (MNR) <David.John.Thompson_at_ontario.ca>
Date: Wed, 04 Jun 2008 15:03:51 -0400


Hello,

A few questions about the following examples: 1. Why do the two plotting versions not produce the same result? 2. Is the 'scale_x_continuous' (or *_y_* or *_*_discrete) geom the best way to setup grids (as in visual guide-lines) in polar (or for that matter, any) coordinate system?
3. Why do these commands appear to generate 3 plot pages each? 4. Perhaps more questions to follow ;-)

### the data

test <- structure(list(oplt = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), rplt = 1:10, az = c(57L, 94L, 96L, 152L, 182L, 185L, 227L, 264L, 332L, 354L), dist = c(4.09, 2.8, 7.08, 7.09, 3.28, 7.85, 6.12, 1.97, 7.68, 7.9)), .Names = c("oplt", "rplt", "az", "dist" ), row.names = c(NA, 10L), class = "data.frame")

labs <- structure(list(oplt = c(0, 0, 0, 0, 0), rplt = structure(c(3L, 1L, 4L, 5L, 2L), .Label = c("E", "N", "o", "S", "W"), class = "factor"),

    az = c(0, 90, 180, 270, 360), dist = c(0, 16, 16, 16, 16)), .Names = c("oplt",
"rplt", "az", "dist"), row.names = c(NA, -5L), class = "data.frame")

### plot version 1, setup plot structure first, add 'data' points later
ggplot() + coord_polar() +
layer( data = labs, mapping = aes(x = az, y = dist, label = rplt), geom = "text") +
scale_x_continuous(breaks=c(90, 180, 270, 360)) + layer( data = test, mapping = aes(x = az, y = dist, label = rplt), geom = "text")

### plot version 2, try the same all in one step
ggplot() + coord_polar() +
layer( data = test, mapping = aes(x = az, y = dist, label = rplt), geom = "text") +
scale_x_continuous(breaks=c(90, 180, 270, 360), labels=c('90', '180', '270', '360'))

### the scenario

I am generating graphics to show the physical layout of a forestry research experiment.
There are 54 'cut blocks' (64x64m, 0.4ha) each containing 1 circular 'overstory plot' (16m radius, 0.08ha).
Each 'overstory plot' (oplt) contains 10 circular 'regeneration plots' (rplt) (0.56m radius, 1m^2 or 1.13m radius, 4m^2), these are the label data points plotted below, later to have the 1m^2 or 4m^2 rplt outline added.
Later, each individual tree will be plotted across each oplt in the views below and each rplt in expanded views. All locations (rplt centers, tree positions) are recorded as azimuth and distance from their respective plot centers, hence my inclination to use polar coordinates.

Thanx, DaveT.



Silviculture Data Analyst
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
david.john.thompson_at_ontario.ca
http://ontario.ca/ofri

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. Received on Wed 04 Jun 2008 - 19:53:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 Jun 2008 - 20:32:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive