stat_contour

Showing 1-4 of 4 messages
stat_contour Robert Bayesian 7/31/11 10:42 AM
Hi,
I looked for an option in stat_contour  that allows me to draw values of z-axis within contour lines as in ?contour {graphics} but I have not found. Is this possible?

Robert   
Re: stat_contour Ista Zahn 7/31/11 11:16 AM
Hi Robert,
While you can probably do this in ggplot2 with some effort, the
directlabels package makes it really easy:


library(directlabels)
volcano3d <- melt(volcano)
names(volcano3d) <- c("x", "y", "z")
v <- ggplot(volcano3d, aes(x, y, z = z))
v2 <- v + stat_contour(aes(colour = ..level..))
direct.label(v2)
direct.label(v2,"top.points")

Note that this example is from
http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=directlabels:direct.label

Best,
Ista

> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>

--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

Re: stat_contour Robert Bayesian 8/1/11 12:22 AM
Thank you for the solution. I see one problem with the package you mentioned. It doesn't put the number between contour lines. please see the difference:

contour(volcano) 

Moreover, it requires colour aes(colour = ..level..) though I don't want.
Using ggplot2 I wanted to get:

par(las=1, mar=c(2,2,0,0), mgp=c(2,.7,0), tck=-.01, cex=0.8)
contour(volcano, labcex = 0.8 )
abline(h=seq(0,1,0.2), v=seq(0,1,0.2), col="gray80")

Rob

2011/7/31 Ista Zahn <iz...@psych.rochester.edu>

Re: stat_contour Ista Zahn 8/1/11 7:52 AM
Hi Rob,

On Mon, Aug 1, 2011 at 3:22 AM, Robert Bayesian
<robert....@gmail.com> wrote:
> Thank you for the solution. I see one problem with the package you
> mentioned. It doesn't put the number between contour lines.

Take a look at the directlabels docs. I think you can have fairly fine
control over where the labels appear, though I wasn't able to figure
it out without devoting more time that I have.

please see the
> difference:
>
> contour(volcano)
>
> Moreover, it requires colour aes(colour = ..level..) though I don't want.

Second part is easy enough, if a bit silly. Just set the color scale
to start and end on the same value

direct.label((v2 + scale_color_gradient(low = "#000000", high = "#000000")))