Your example works fine for me* (using R 2.14.1, ggplot 0.9), with
both the snippet you posted and a file from that website. Perhaps
check "summary(SF.bath)" and make sure all three numbers are correctly
numeric? Just a guess.
Ben
*Note however there's an inconsistency in what you posted--you're
assigning the column name "long" to the first column of the data in
read.table, but asking ggplot to plot "lon".
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
Hmm, this example also works perfectly for me. It looks like the error
is coming from the reshape2 package...my guess would be that there are
multiple values for some x-y, and that's screwing things up. Try first
summarizing your data frame so that there's only one unique z for each
x/y combinatione.g.:
SF.bath.ag <- aggregate(z ~ long+lat, data=SF.bath,FUN=mean)
...and then plot that.
Ben
R version 2.14.1 (2011-12-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_0.9.0
loaded via a namespace (and not attached):
[1] colorspace_1.1-0 dichromat_1.2-4 digest_0.5.1
grid_2.14.1 MASS_7.3-16 memoise_0.1 munsell_0.3
[8] plyr_1.6 proto_0.3-9.2 RColorBrewer_1.0-5
reshape2_1.2.1 scales_0.2.0 stringr_0.6
This is weird... I've tried your suggestion but I still get the same result.
I've also looked at the following example and get the same problem: "Using alpha as value column: use value_var to override."
library("reshape2")
volcano3d <- melt(volcano)
names(volcano3d) <- c("lon", "lat", "z")
v <- ggplot(volcano3d, aes(lon, lat,z=z))
print(v + geom_raster(aes(fill=z)) + stat_contour(size=0.2) + scale_fill_gradient("z"))
I still get this white plot with my contour line... :(
-Aurelie
Sam
> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
[5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_0.9.0 reshape2_1.2.1
loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2 grid_2.14.1
[5] MASS_7.3-17 memoise_0.1 munsell_0.3 plyr_1.7.1
[9] proto_0.3-9.2 RColorBrewer_1.0-5 scales_0.2.0 stringr _0.6
> sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] C/en_US.UTF-8/C/C/C/C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reshape2_1.1 ggplot2_0.9.0
loaded via a namespace (and not attached):
[1] MASS_7.3-17 RColorBrewer_1.0-5 colorspace_1.1-0
[4] dichromat_1.2-4 digest_0.5.1 grid_2.14.2
[7] memoise_0.1 munsell_0.3 plyr_1.6
[10] proto_0.3-9.2 scales_0.2.0 stringr_0.5
[13] tools_2.14.2