如何在R/ggplot中剪切图形?
R 我有以下代码:如何在R/ggplot中剪切图形?,r,ggplot2,graph,R,Ggplot2,Graph,R 我有以下代码: ggsurvplot(curve.histology, conf.int=TRUE, legend.labs=legend.histology, surv.scale=c("percent"),risk.table=T, ggtheme = theme_bw(), risk.table.fontsize=3.5, xlim=c(0,5), ylim=c(0,1), break.time.by=1) “曲线组织学”中有四个变量。我希望所有四个图形都停止在x=5,就像我的
ggsurvplot(curve.histology, conf.int=TRUE,
legend.labs=legend.histology, surv.scale=c("percent"),risk.table=T,
ggtheme = theme_bw(), risk.table.fontsize=3.5, xlim=c(0,5),
ylim=c(0,1), break.time.by=1)
“曲线组织学”中有四个变量。我希望所有四个图形都停止在x=5,就像我的x轴一样。有人能帮忙吗
curve.orbiologyIIUC,在coord\u cartesian()
上设置xlim
和expand=0L
可能会有所帮助(只要按theme()
排列边距即可)。但是,我认为您应该向survminer包的存储库提交一个问题,因为在ggsurvplot中编辑ggplot对象有点痛苦
reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-11-12
library(survminer)
#> Loading required package: ggplot2
#> Loading required package: ggpubr
#> Loading required package: magrittr
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
p <- ggsurvplot(fit, data = lung, xlim = c(0, 900), expand = FALSE)
p$plot <- p$plot +
coord_cartesian(xlim = c(0, 900), expand = FALSE) +
theme(plot.margin = margin(5.5, 20, 5.5, 5.5))
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
p
reprex::reprex_info()
#>由2017年11月12日的reprex包v0.1.1.9000创建
图书馆(survminer)
#>加载所需包:ggplot2
#>加载所需包:ggpubr
#>装载所需包装:magrittr
图书馆(生存)
你能给我一个曲线样本吗?很难知道没有这些数据会发生什么…我在正文中添加了一个图像
reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-11-12
library(survminer)
#> Loading required package: ggplot2
#> Loading required package: ggpubr
#> Loading required package: magrittr
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
p <- ggsurvplot(fit, data = lung, xlim = c(0, 900), expand = FALSE)
p$plot <- p$plot +
coord_cartesian(xlim = c(0, 900), expand = FALSE) +
theme(plot.margin = margin(5.5, 20, 5.5, 5.5))
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
p