Thanx Hadley, More questions inline.
>-----Original Message----- >From: hadley wickham [mailto:[EMAIL PROTECTED] >Sent: June 5, 2008 01:09 PM >To: Thompson, David (MNR) >Cc: r-help@r-project.org >Subject: Re: [R] ggplot questions > >On Wed, Jun 4, 2008 at 2:03 PM, Thompson, David (MNR) ><[EMAIL PROTECTED]> wrote: >> Hello, >> >> A few questions about the following examples: >> 1. Why do the two plotting versions not produce the same result? > >Because version one has two layers, and version two has one? Does the difference have something to do with ggplot() using ranges derived from the data? When I modify my original 'test' dataframe with two extra rows as defined below, I get expected results in both versions. This highlights my next question (warned you ;-) ), I have been unsuccessful in trying to define fixed plotting ranges to generate a 'template' graphic that I may reuse with successive 'overstory plot' data sets. I have used '+ xlim(0, 360) + ylim(0, 16)' but, this seems to not have any effect on the final plot layout. > >> 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? > >It's one way. Another way is to use geom_hline and geom_vline. (Also >note that scale_x_continuous is a _scale_ not a geom) OK. So, how do I suppress automatic generation of plot grids so that I could define my own with geom_hline and geom_vline? > >> 3. Why do these commands appear to generate 3 plot pages each? > >Could you provide a bit more detail here please? Sorry Hadley, I could not reproduce the same behaviour. I had restarted my computer since then so, maybe, I was just suffering from the usual leaky-resources-M$-syndrome. > >Thanks, > >Hadley > >-- >http://had.co.nz/ # for ease of reference: # the two original dataframes 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") # the new dataframe test2 <- structure(list(oplt = c(0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), rplt = c("o", "N", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"), az = c(0, 360, 57, 94, 96, 152, 182, 185, 227, 264, 332, 354), dist = c(0, 16, 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, 12L), 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')) > sessionInfo() R version 2.7.0 (2008-04-22) i386-pc-mingw32 locale: LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY= English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252 attached base packages: [1] datasets grDevices splines grid graphics stats tcltk utils methods base other attached packages: [1] ggplot2_0.6 colorspace_0.95 RColorBrewer_1.0-2 MASS_7.2-42 proto_0.3-8 reshape_0.8.0 car_1.2-8 [8] svSocket_0.9-5 svIO_0.9-5 R2HTML_1.59 svMisc_0.9-5 svIDE_0.9-5 Thanx again, DaveT. ************************************* Silviculture Data Analyst Ontario Forest Research Institute Ontario Ministry of Natural Resources [EMAIL PROTECTED] http://ontario.ca/ofri ______________________________________________ R-help@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.