[R] Organising tick-marks in plot()
Katharine Mullen
kate at few.vu.nl
Fri Nov 30 14:19:32 CET 2007
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.
>
More information about the R-help
mailing list