Is there any simple way to add text to the x axis in R? I have tried to add simple characters in R without any greater sucess. As an example of what I want to do is the added C in the following "dumb" plot (produced with MacAnova using the option "dumb:T"): ++------+-------+------+-------+------+-------+------+-------++ 1+ : *+ | : * * | | : * * | | : * . | 0.8+ : * . + | : . | | : * . | | : * . | 0.6+ : . + | : * . | | * . | | : . | | * : . | 0.4+ : . + | * : . | | * : . | | : . | 0.2+ * : . + | * : . | | * * : . | |* * * : . | 0++------+-------+------+-------+------+-------+--.---+-------++ -2 -1.5 -1 -0.5 0 0.5 1 C 1.5 2 My attempts to use locator() and text() in R's plot() has not been working as good as expected. Never really knows where the added symbols end up... BTW, anyone who knows how such "dumb" plots could be achieved in R? This option is avaliable in S, so a port to R shouldn't be impossible, should it? Don't know how to do it myself however... Robert
Hi maybe something like> plot(1:10,1:10, axes=F) > axis(1, at=1:10, labels=c((1:7)/10, "c", 9:10)) > axis(2, at=1:10, labels=c(letters[1:5], 6:10)) > box() >HTH Petr On 30 May 2006 at 14:45, Robert Lundqvist wrote: To: r-help at stat.math.ethz.ch From: Robert Lundqvist <Robert.Lundqvist at ltu.se> Date sent: Tue, 30 May 2006 14:45:41 +0200 Subject: [R] Add text/numbers to x axis? Send reply to: Robert.Lundqvist at ltu.se <mailto:r-help-request at stat.math.ethz.ch?subject=unsubscribe> <mailto:r-help-request at stat.math.ethz.ch?subject=subscribe>> Is there any simple way to add text to the x axis in R? I have tried > to add simple characters in R without any greater sucess. As an > example of what I want to do is the added C in the following "dumb" > plot (produced with MacAnova using the option "dumb:T"): > > ++------+-------+------+-------+------+-------+------+-------++ > 1+ : *+ > | : * * | | > : * * | | > : * . | > 0.8+ : * . + > | : . | | > : * . | | > : * . | > 0.6+ : . + > | : * . | | > * . | | > : . | | > * : . | > 0.4+ : . + > | * : . | | > * : . | | > : . | > 0.2+ * : . + > | * : . | | > * * : . | |* * > * : . | > 0++------+-------+------+-------+------+-------+--.---+-------++ > -2 -1.5 -1 -0.5 0 0.5 1 C 1.5 2 > > > My attempts to use locator() and text() in R's plot() has not been > working as good as expected. Never really knows where the added > symbols end up... > > BTW, anyone who knows how such "dumb" plots could be achieved in R? > This option is avaliable in S, so a port to R shouldn't be impossible, > should it? Don't know how to do it myself however... > > Robert > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz
Robert Lundqvist <Robert.Lundqvist at ltu.se> writes:> Is there any simple way to add text to the x axis in R? I have tried to > add simple characters in R without any greater sucess. As an example of > what I want to do is the added C in the following "dumb" plot (produced > with MacAnova using the option "dumb:T"): > > ++------+-------+------+-------+------+-------+------+-------++ > 1+ : *+ > | : * * | > | : * * | > | : * . | > 0.8+ : * . + > | : . | > | : * . | > | : * . | > 0.6+ : . + > | : * . | > | * . | > | : . | > | * : . | > 0.4+ : . + > | * : . | > | * : . | > | : . | > 0.2+ * : . + > | * : . | > | * * : . | > |* * * : . | > 0++------+-------+------+-------+------+-------+--.---+-------++ > -2 -1.5 -1 -0.5 0 0.5 1 C 1.5 2 > > > My attempts to use locator() and text() in R's plot() has not been working > as good as expected. Never really knows where the added symbols end up...mtext() is your friend.> BTW, anyone who knows how such "dumb" plots could be achieved in R? This > option is avaliable in S, so a port to R shouldn't be impossible, should > it? Don't know how to do it myself however...Presumably you "just" need someone to write a device driver for it. The structure of those is somewhat different from S, so it's not a straightforward port (even if the S code was publically available). As I recall it (fortunately, it was decades ago), some cosmetic issues become tricky due to the high granularity of such line printer plots; things like alignment of strings and continuation of polylines. However if someone wants to read up on Bresenham's line drawing algorithm and all that... -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
On Tue, 30 May 2006, Robert Lundqvist wrote:> Is there any simple way to add text to the x axis in R? I have tried to > add simple characters in R without any greater sucess. As an example of > what I want to do is the added C in the following "dumb" plot (produced > with MacAnova using the option "dumb:T"): > > ++------+-------+------+-------+------+-------+------+-------++ > 1+ : *+ > | : * * | > | : * * | > | : * . | > 0.8+ : * . + > | : . | > | : * . | > | : * . | > 0.6+ : . + > | : * . | > | * . | > | : . | > | * : . | > 0.4+ : . + > | * : . | > | * : . | > | : . | > 0.2+ * : . + > | * : . | > | * * : . | > |* * * : . | > 0++------+-------+------+-------+------+-------+--.---+-------++ > -2 -1.5 -1 -0.5 0 0.5 1 C 1.5 2 > > > My attempts to use locator() and text() in R's plot() has not been working > as good as expected. Never really knows where the added symbols end up...Well, they end up where you request them. In that particular case I would use axis() to add a label that matched the tick marks, but mtext() is often useful.> BTW, anyone who knows how such "dumb" plots could be achieved in R? This > option is avaliable in S, so a port to R shouldn't be impossible, should > it? Don't know how to do it myself however...There is the little matter of having access to the S source code and permission to make use of it, as well as knowing how the S graphics device model works (which AFAIK has never been publicly documented but it believed to be somewhat different from R). The devil is in the details: notice how the y axis on the plot shown is uneven, with a stretch in the middle? Should such things be allowed (I think not)? -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
> BTW, anyone who knows how such "dumb" plots could be achieved in R? This > option is avaliable in S, so a port to R shouldn't be impossible, should > it? Don't know how to do it myself however...Use gnuplot or MacAnova. RSiteSearch("MacAnova") has an example.