[R] ggplot questions
Thompson, David (MNR)
David.John.Thompson at ontario.ca
Wed Jun 4 21:03:51 CEST 2008
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
More information about the R-help
mailing list