Re: [R] Organising tick-marks in plot()

From: Katharine Mullen <kate_at_few.vu.nl>
Date: Fri, 30 Nov 2007 14:19:32 +0100 (CET)

something like this sounds like what you want:

labs<-NA
x<-200

for(i in 1:5){ labs<-append(labs, c(rep(NA,3),x)); x<-x+200 }

plot(1:900, xaxt="n", xlim=c(0, 1000))
axis(side = 1, at = seq(0,1000,by=50), labels=labs)

On Fri, 30 Nov 2007 Ted.Harding_at_manchester.ac.uk wrote:

> Hi Folks,
> I'm advising someone who's a beginner with R,
> and therefore wants the simplest answer possible.
>
> The issue is to produce a plot using
>
> plot(x,y,...)
>
> where, on the X-axis, the tick-marks should be
> on the lines of:
>
> -- Range of X-axis: 0:1000
> -- tick-marks labelled "0","200",...,"800","1000"
> -- unlabelled tick-marks every 50 from 0 to 1000.
>
> regardless of the actual range of x-values (which
> however would normally range over most of 0:1000).
>
> I've looked at the Q-Q Plot example in the MASS
> book (Section 3.4), which does achieve this kind
> of effect, but the code is too complicated for
> the present context. (Whatever code is used needs
> to be readily changeable for different plots of
> the same general kind).
>
> Is there a way of supplying straightforward
> arguments to plot() which would achieve this?
>
> I've been reading and site-searching for a while,
> and the best I can find is on the lines of
>
> plot((x,y,pch="+",col="blue",xlim=c(0,1000),xaxt="n")
> par(xaxp=c(0, 1000, 50))
> axis(1)
>
> which is already complicated enough in the present
> context; but it doesn't do exactly what is required
> since (for example) if the x-values range from
> 0 to 900 the labelled tick-marks are at
>
> 0 60 140 220 300 380 460 540 620 700 780 860 940
>
> and have therefore been computed from the range of
> the data, and not from the specified range of the x-axis.
>
> Help please!
> Best wishes to all,
> Ted.
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding_at_manchester.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 30-Nov-07 Time: 11:55:16
> ------------------------------ XFMail ------------------------------
>
> ______________________________________________
> R-help_at_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.
>



R-help_at_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. Received on Fri 30 Nov 2007 - 13:23:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 30 Nov 2007 - 15:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.