修改 'survrec' 包中的图表
Modifying graphs in 'survrec' package
我是 R 的新手,我正在使用包 'survrec'。我想修改多组图表中的颜色和线条。该软件包包括此示例:
data(colon)
# fit a pena-strawderman-hollander and plot it
fit<-survfitr(Survr(hc,time,event)~as.factor(dukes),data=colon,type="pena")
plot(fit,ylim=c(0,1),xlim=c(0,2000))
像在其他图表或 "survfit" 对象中一样使用参数 "col" 或 "lty" 不起作用。
plot(fit,ylim=c(0,1),xlim=c(0,2000), col=c("red", "blue", "orange"), lty=3)
使用 palette
影响底图的调色板并使用 par
修改其他参数默认值:
library(survrec)
library(viridis)
data(colon)
fit<-survfitr(Survr(hc,time,event)~as.factor(dukes),data=colon,type="pena")
palette(viridis(3))
plot(fit,ylim=c(0,1),xlim=c(0,2000))
palette(c("#7f3b08", "#2d004b", "#1b7837"))
plot(fit,ylim=c(0,1),xlim=c(0,2000))
palette(c("red", "blue", "orange"))
par(lty=3)
plot(fit,ylim=c(0,1),xlim=c(0,2000))
不幸的是,survrec:::plot.survfitr
对 upper/lower 行进行了硬编码 lty=2
。如果需要,您可以复制该函数并对其进行参数化。
我是 R 的新手,我正在使用包 'survrec'。我想修改多组图表中的颜色和线条。该软件包包括此示例:
data(colon)
# fit a pena-strawderman-hollander and plot it
fit<-survfitr(Survr(hc,time,event)~as.factor(dukes),data=colon,type="pena")
plot(fit,ylim=c(0,1),xlim=c(0,2000))
像在其他图表或 "survfit" 对象中一样使用参数 "col" 或 "lty" 不起作用。
plot(fit,ylim=c(0,1),xlim=c(0,2000), col=c("red", "blue", "orange"), lty=3)
使用 palette
影响底图的调色板并使用 par
修改其他参数默认值:
library(survrec)
library(viridis)
data(colon)
fit<-survfitr(Survr(hc,time,event)~as.factor(dukes),data=colon,type="pena")
palette(viridis(3))
plot(fit,ylim=c(0,1),xlim=c(0,2000))
palette(c("#7f3b08", "#2d004b", "#1b7837"))
plot(fit,ylim=c(0,1),xlim=c(0,2000))
palette(c("red", "blue", "orange"))
par(lty=3)
plot(fit,ylim=c(0,1),xlim=c(0,2000))
不幸的是,survrec:::plot.survfitr
对 upper/lower 行进行了硬编码 lty=2
。如果需要,您可以复制该函数并对其进行参数化。