根据事件状态绘制后续时间分布图

问题描述 投票:0回答:1

我想根据 y 轴上变量

futime
中的事件状态创建变量
fustat
在 x 轴上的后续时间分布图。

data(cancer, package="survival")

我的尝试:

library(ggplot2)
ggplot(ovarian, aes(x = futime, fill = factor(fustat))) +
  geom_histogram(binwidth = 50) +
  labs(x = "Futime", y = "Count", fill = "Fustat") +
  scale_fill_manual(values = c("0" = "red", "1" = "blue")) +
  theme_minimal()

但是如何让它变得更好,就像this

谢谢

r ggplot2 survival-analysis
1个回答
0
投票

使用内置数据集的示例,因为我们没有您的数据:

library(ggplot2)
ggplot(iris, aes(x = Sepal.Length, fill = factor(Species))) +
  geom_histogram(binwidth = 0.2, alpha = 0.4, position = "identity")

给出:

© www.soinside.com 2019 - 2024. All rights reserved.