How to suppress default legend in plot.cuminc()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to suppress default legend in plot.cuminc()

Lamke
This post has NOT been accepted by the mailing list yet.
Hi there,

I wonder if there's a way to suppress the legend automatically generated by plot.cuminc() in the cmprsk package.
Here's an example from cuminc()

set.seed(2)
ss <- rexp(100)
gg <- factor(sample(1:3,100,replace=TRUE),1:3,c('a','b','c'))
cc <- sample(0:2,100,replace=TRUE)
strt <- sample(1:2,100,replace=TRUE)
print(xx <- cuminc(ss,cc,gg,strt))
plot(xx,lty=1,color=1:6)

I've tried legend=FALSE as a plot parameter but it doesn't work.

Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: How to suppress default legend in plot.cuminc()

Dan E.
This post has NOT been accepted by the mailing list yet.
Hi there,

The legend can not be suppressed, but you can name the values in it for your plot.

Here is how to do it:

x<-cuminc(bep1$ftime,bep1$status)

plot(x,lty=1,xaxt="n",curvlab=c("lion","bear","wolf","unknown","natural","unknown predator"),ylim=c(0,0.5),col=2:7,lwd=1, main="2011 CIFs",xlab="Calendar Days")
axis(1,c(0,30,60,90,120,150,180,210,240,270,300,330,360))

The curvlab() function allows you to name the categories in the legend.

Hope this helps.

-Dan
rob
Reply | Threaded
Open this post in threaded view
|

Re: How to suppress default legend in plot.cuminc()

rob
In reply to this post by Lamke
You could also try the following:
 
plot(xx,lty=1,color=1:6,wh=c(0,3))

The wh-argument sets the coordinates for the topleft corner of the legend-box. By giving coordinates that fall outside the plot no legend will appear. You can later add a custom legend with the legend()-function.

Hope this works for you,
Rob