On Dec 20, 2010, at 5:36 AM, Andre Nathan wrote:

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 don't see it, but that doesn't mean much unless it is echoed by Sarkar or Andrews.

I tried
setting labels = F and then calling text() for each one, but that
doesn't work.

Right, text() is a base graphics function. There are, however, lattice functions that supply the same functionality:

?ltext   # = l(attice)text

ltext(x, y = NULL, labels = seq_along(x), col, alpha, cex, srt = 0, lineheight, font, fontfamily, fontface, adj = c(0.5, 0.5), pos = NULL, offset = 0.5, ...) You could first see if you can better results by not automatically labeling the 10^-6 level, because the -2, -3, -5 levels look ok. That might let the 10^-4 label move to a bit less hashed up position and then you could put 10^-1 and 10^-6 where you want them


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?

..., scales=list(tck=c(1,0)), ... actually you would add the tck list to your existing scales. Found on the ?xyplot page, but tested with a modified volcano example from :
?contourplot



Thanks,
Andre

David Winsemius, MD
West Hartford, CT

______________________________________________
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.

Reply via email to