[R] contourplot help

Andre Nathan andre at digirati.com.br
Mon Dec 20 11:36:02 CET 2010


Hello

I'm using the following call to create a contourplot:

library(lattice)
m <- as.matrix(read.table("data.txt"))

contourplot(m[,3] ~ m[,2] * -m[,1],
            at = c(1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1),
            scales = list(x = list(log = 10,
                                   labels = c("1", "10", "100"),
                                   at = c(1, 10, 100)),
                          y = list(labels = c("14", "12", "10", "8",
                                              "6", "4", "2")),
                                   at = c(-14, -12, -10, -8, -6, -4,
                                          -2)),
            labels = c(expression(10^-6), expression(10^-5),
                       expression(10^-4), expression(10^-3),
                       expression(10^-2), expression(10^-1),
                       expression(10^0)),
            xlim = c(0.75, 10^2),
            xlab = "Out-degree", ylab = "In-degree")


Which gives the the output in the file below

  http://ompldr.org/vNm4xag/contour.eps

As it can be seen, the level labels are not displayed nicely because
there's not enough room for them. Also, the 10^-1 label is not
displayed.

Is there a way for me to hardcode the position of each label? I tried
setting labels = F and then calling text() for each one, but that
doesn't work.

If that's not possible, one option would be to color each level line
differently and then add a legend. Is it possible to do that?

Finally, how can I remove the tick marks from the top and right axes?

Thanks,
Andre



More information about the R-help mailing list