andreas.krause@pharma.novartis.com
2002-May-21 15:21 UTC
[R] using axis with newline characters
Wondering if I missed anything or if that's a problem with R: I want to have many x axis tickmarks and labels such that it makes sense to put them on multiple "lines". The newline character seems to be ignored though for axis labels: plot(1:33, axes=F) axis(1, 9, 9) axis(1, 11, "\n11") axis(1) # whereas title("one\ntwo") works as I expect it to work. In addition there is a little hook on top of the tickmark (the upper end of the vertical dash) that seems to be unintended. Best regards, Andreas Krause PS. R version 1.4.1 on Red Hat Linux. PPS. One way to do what I want to achieve is to use axis with the line parameter, but this requires breaking up the labels. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, On Tue, 21 May 2002 andreas.krause at pharma.novartis.com wrote: |Wondering if I missed anything or if that's a problem with R: |I want to have many x axis tickmarks and labels such that it makes sense to put them on multiple "lines". |The newline character seems to be ignored though for axis labels: | |plot(1:33, axes=F) |axis(1, 9, 9) |axis(1, 11, "\n11") |axis(1) Use par(mgp). Example:> plot(1:33) > par(mgp=c(3,2,0)) > axis(1,9,9)Was it what you wanted? Cheers, Ott -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi> Wondering if I missed anything or if that's a problem with R: > I want to have many x axis tickmarks and labels such that it makes sense to put them on multiple "lines". > The newline character seems to be ignored though for axis labels: > > plot(1:33, axes=F) > axis(1, 9, 9) > axis(1, 11, "\n11") > axis(1)The problem here is that axis() (and mtext()) control the vertical adjustment of text (based on the setting of par(las)). The whole piece of text "\n11" is being bottom-adjusted in your example. This is easier to see if you add the following command to your example ... axis(1, 13, "one\ntwo") ... does the following example let you do what you want? plot(1:33, axes=F) par(mgp=c(3, 2, 0)) axis(1, at=c(seq(0, 30, 5), 8, 12), labels=c(paste(seq(0, 30, 5), "\n"), "8\n", "\n12")) Paul -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._