I am sorry that this is another novice question. I am having trouble using "legend" with the survival curve plot from the survival package, and I wonder if it is because I have rescaled my plot. Here is the relevant segment of code:> plot(survfit(Surv(OS,Status)~shortishcr1),main='Overall Survival byfactor', + xlab='Years',ylab='% surviving',lty=c(1,2),xscale=365.25,yscale=100)> legend(5,80,c('Factor=1','Factor=2'),lty=c(1,2))Here the variable OS is in days, but I want to plot it in years, so I scale it; likewise y is scaled to a percentage. I am trying to position the legend in the rescaled x and y values. Legend returns no error, but no legend appears on the plot. If I exclude the scaling altogether:> plot(survfit(Surv(OS,Status)~shortishcr1),main='Overall Survival byfactor', + xlab='Years',ylab='% surviving',lty=c(1,2),)> legend(1825,.8,c('Factor=1','Factor=2'),lty=c(1,2))then the legend appears exactly as expected. Using the unscaled version of the legend call with the scaled plot, however, again no legend appears but no error is returned. I suspect I am making some elementary mistake, but I just can't see it. It is so elementary that I can't find a similar question in the archives. Can someone help? Here is my version information: _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 0.1 year 2004 month 11 day 15 language R Rachel
Rachel Pearce wrote:> I am sorry that this is another novice question. I am having trouble > using "legend" with the survival curve plot from the survival package, > and I wonder if it is because I have rescaled my plot. > > Here is the relevant segment of code: > > >>plot(survfit(Surv(OS,Status)~shortishcr1),main='Overall Survival by > > factor', > + xlab='Years',ylab='% surviving',lty=c(1,2),xscale=365.25,yscale=100) > >>legend(5,80,c('Factor=1','Factor=2'),lty=c(1,2)) > > > Here the variable OS is in days, but I want to plot it in years, so I > scale it; likewise y is scaled to a percentage. > I am trying to position the legend in the rescaled x and y values. > Legend returns no error, but no legend appears on the plot.Ask for the real coordinatre system using par("usr") and place the legend somewhere appropriate within these user coordinates. Uwe Ligges> If I exclude the scaling altogether: > > >>plot(survfit(Surv(OS,Status)~shortishcr1),main='Overall Survival by > > factor', > + xlab='Years',ylab='% surviving',lty=c(1,2),) > >>legend(1825,.8,c('Factor=1','Factor=2'),lty=c(1,2)) > > > then the legend appears exactly as expected. > > Using the unscaled version of the legend call with the scaled plot, > however, again no legend appears but no error is returned. > > I suspect I am making some elementary mistake, but I just can't see it. > It is so elementary that I can't find a similar question in the > archives. Can someone help? > > Here is my version information: > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 0.1 > year 2004 > month 11 > day 15 > language R > > > Rachel > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html