[R] x axis

Marc Schwartz MSchwartz at mn.rr.com
Tue Dec 20 15:33:32 CET 2005

On Tue, 2005-12-20 at 12:56 +0100, Michela Ballardini wrote:
> Hello,
> I write to know how can I modify the x axis : when I plot a survival
> object, R plots a graph with x values = 0, 10, 20, 30 while I want a
> graph with values 0, 6, 12, 18, 24 in the x axis. How can I do this?
> In R 2.1.1 version there was "time.inc" in survplot, but in version R
> 2.2.0 there isn't it!
> I am sorry for my english and I hope that you understand my problem.
> Thank you 
> Michela

I suspect that you are confusing the arguments available for
plot.survfit() which is in the 'survival' package as part of the
standard R installation, with survplot() which is in Frank Harrell's
'Design' package, which needs to be installed from CRAN.

The former does not have a 'time.inc' argument, while the latter does
(and still does).

You probably need to install Design in your updated R installation,
since under Windows (from your e-mail headers), R is installed in
version specific directories. 

Then be sure to use library(Design) before using survplot().

Even with plot.survfit(), one can adjust the x axis labels by using
something like the following (an example from ?plot.survfit):

leukemia.surv <- survfit(Surv(time, status) ~ x, data = aml)

# Now compare the default labels here:
plot(leukemia.surv, lty = 2:3)

# With these:

# Set 'xaxt = "n"' so the x axis is not drawn
plot(leukemia.surv, lty = 2:3, xaxt = "n")

# Now draw x axis with labels every 6 months
# Make the font smaller to fit in this example
axis(1, at = seq(0, 172, 6), cex.axis = 0.5)


Marc Schwartz

More information about the R-help mailing list