On 15/02/2013, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > On 13-02-15 3:28 AM, e-letter wrote: >> On 15/02/2013, Jim Lemon <j...@bitwrit.com.au> wrote: >>> On 02/14/2013 09:41 PM, e-letter wrote: >>>> Readers, >>>> >>>> For this data set: >>>> >>>> testvalues<-c(10,20,30,40) >>>> >>>> How to amend the plot instruction: >>>> >>>> plot(testvalues,ann=FALSE,type='l',yaxt='n',xaxt='n') >>>> >>>> so that x axis ticks labels can be added to existing graph with >>>> arbitrary value such as 0,100,200,300)? >>>> >>> Hi r2151, >>> If you want the labels to fit on the axis you will have to include this >>> information in the call to "plot": >>> >>> plot(testvalues,ann=FALSE,type='l',yaxt='n',xaxt='n',ylim=c(0,300)) >>> axis(2,at=c(0,100,200,300)) >>> >> >> plot(testvalues,ann=FALSE,type='l',yaxt='n',xaxt='n',xlim=c(0,300)) >> axis(1,at=c(0,100,200,300)) >> >> The use of 'xlim' makes the graph unacceptable. Instead, it would be >> better to plot: >> >> plot(testvalues,ann=FALSE,type='l',yaxt='n') >> >> The x-axis shows tick marks '1.0', '1.5', ... >> >> It is required to replace these values with custom values (e.g. 10, 20... >> etc.) > > Why not rescale the values before plotting, and use the automatic ticks? > You can lie about the user scale, but it doesn't always give a helpful > plot, e.g. > > axis(1, at=1:4, labels=c(100, 300, 400, 200)) >
Tried, but realised that this works when the vectors for 'at' and 'labels' are equal size. For a data set of e.g. 10 values, syntax error returns. ______________________________________________ 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.