R ggsurvplot 不要标签
时间: 2023-06-18 20:02:02 浏览: 85
如果你想在 R 的 ggsurvplot 中去掉标签,可以使用参数 legend.labs = NULL。下面是一个例子:
```r
library(survminer)
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, legend.labs = NULL)
```
这将绘制一个没有标签的生存曲线。
相关问题
R ggsurvplot 不要“Strata”标签
如果您不想在 `ggsurvplot` 的输出中包含“Strata”标签,可以使用 `survminer` 包中的 `ggsurvplot()` 函数的 `risk.table = FALSE` 参数来实现。这将删除风险表和标签。
下面是一个示例代码:
```r
library(survminer)
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data = lung,
risk.table = FALSE, # 不显示风险表
legend.labs = c("Male", "Female"), # 自定义图例标签
xlab = "Time in Days", ylab = "Survival Probability",
ggtheme = theme_bw())
```
您可以根据需要自定义其他参数,例如 `legend.labs` 参数来更改图例标签。
R ggsurvplot 不要图例
如果你想使用 `ggsurvplot` 函数绘制生存曲线图而不包含图例,可以将参数 `legend.labs` 设置为 `NULL`。下面是一个示例代码:
```R
library(survival)
library(survminer)
# 加载数据
lung <- lung
# 拟合生存模型
fit <- survfit(Surv(time, status) ~ sex, data = lung)
# 绘制生存曲线图
ggsurvplot(fit, legend.labs = NULL)
```
在上面的代码中,我们使用了 `survival` 和 `survminer` 包中的函数来加载数据和绘制生存曲线图。在 `ggsurvplot` 函数中,我们将 `legend.labs` 参数设置为 `NULL`,这样就可以去掉图例。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)