[R] Problem with axes in a plot of Kaplan-Meier

David Winsemius dwinsemius at comcast.net
Thu Jan 5 21:41:17 CET 2012


On Jan 5, 2012, at 12:50 PM, correu griera wrote:

> Helo:
>
> After changing "involuntarily" some of the graphics parameters with
> the command par() (I did not know that changes with this command are
> permanent), now when I made a plot of the survival Kaplan-Meier
> function, the Y axis does not start at 1, and the X axis does starts
> at 0. The commands that I use are:
>
>    library(survival)
>    BROWN.SPV = Surv(BROWN$TEMPS, BROWN$DEF)
>    BROWN.KM = survfit(BROWN.SPV ~ 1)
>    plot(BROWN.KM$time, BROWN.KM$surv, type="s")

I would be happy to be proven wrong, but I don't think so. My idea is  
to add this line to your .Rprofile:

myopar <- par()

Then you can restore in the future with

par(myopar)

(This is untested and at times I fall on my face with initialization  
assumptions. If the graphics package is not loaded at the  
time .Rprofile is interpreted you might need to run require(graphics)  
before that command.)


The usual practice in a console session (if you remember to do this) is:

opar <-par(new-par-specs)
plot-commands
par(opar)

And you should instead be using on.exit if you are writing functions  
to do this.

>
> How can I restore previous graphics parameters? Is there a file that
> would delete to restore the initial settings (already use R in debian
> squeeze)?
>

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list