Hello,
I'm new to ggplot and scoured the archives with no luck. I would like
to to put a legend title for a contour plot on 2 lines as follows:
ggplot(cont, aes(Dist, Ht, fill = SG)) + geom_tile() +
xlab("Radius (cm)") + ylab("Height in stem (m)") +
opts(title = "Wood density") +
scale_fill_gradientn(expression(bold(paste("Density
(",kg~m^-3,")"))), limits = c(300, 675), colours = terrain.colors(7))
However, this only partially works because even though the units are
on a separate line a space is inserted after the opening bracket like
so: ( kg m-3).
I read on one post that control parameters such as \n were
incompatible with plotmath expressions, but I can't find a way to get
around this.
I would also like to set an xlim argument as well but can't see how
this is done.
Thanks in advance for any help.
Dave
> sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United
Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United
Kingdom.1252
attached base packages:
[1] grid grDevices datasets splines graphics stats
tcltk utils methods base
other attached packages:
[1] ggplot2_0.8.8 proto_0.3-8 reshape_0.8.3 plyr_1.2.1
lattice_0.19-13 svSocket_0.9-50 TinnR_1.0.3 R2HTML_2.2
Hmisc_3.8-3
[10] survival_2.35-8
loaded via a namespace (and not attached):
[1] cluster_1.13.1 digest_0.4.2 RColorBrewer_1.0-2
svMisc_0.9-60 tools_2.11.1