[R] tick marks: 0, 12, 24, 36 ...

Marc Schwartz MSchwartz at medanalytics.com
Mon Oct 6 18:41:36 CEST 2003


On Mon, 2003-10-06 at 10:55, Gabor Borgulya wrote:
> Dear R-help list,
> 
> I have a problem with the tick marks of a Kaplan-Meier survival plot.
> Here is a sample:
> 
> follow.up<-c(10,20,30,40,50,60,70,80,90,100) #months
> dead<-c(1,1,1,0,1,1,0,0,0,0)
> KM <-survfit(Surv(follow.up, dead))
> plot(KM)
> 
> The result is a nice plot. However, our research group thinks it may be
> a better idea to place the ticks to the years on the time scale, i.e. 0,
> 12, 24, 36 etc. months. Is this possible with R?
> 
> I tried to look it up and the most relevant manual page was ?axis,
> option at - but I could not make this work together with the plot
> command. 
> 
> plot(KM, axis=axis(1, at=c(0,12,24,36))) #this does not what I wanted
> 
> Any ideas?
> 
> 
> Thank you,
> 
> Gabor


Try the following:

# Plot without the x axis being labeled
plot(KM, xaxt = "n")

# Now draw the x axis labels and tick marks
axis(1, at = c(0, 12, 24, 36, 48, 60, 72, 84, 96))

HTH,

Marc Schwartz




More information about the R-help mailing list