[R] ticks label of plot

Jim Lemon jim at bitwrit.com.au
Thu Aug 5 11:35:53 CEST 2010


On 08/05/2010 07:14 AM, yan liu wrote:
> Hello,
>
> I had a question about how to label a axis of a plot.
>
> for example, my plot is
>
>> plot(1:100, axes=F)
>> box()
>> axis(1)
>
> then, I want my y-axis has six ticks ( at=seq(0,100,10)) , but I don't want
> to label all the 11 ticks, I only want to label the 1st, 3rd, 5th, 7th and
> 11th ticks. But the code axis(), always need the length of the "labels" and
> "at" be equal, and not allow label partially.
>
Hi Yan,
I think you mean that you want to label 6 of the 11 ticks. Try this:

axis(1,at=seq(0,100,10),
  labels=c("1","","3","","5","","7","","9","","11"))

Sneakiness is its own reward.

Jim



More information about the R-help mailing list