Closed huangwb8 closed 1 year ago
Here is an example:
size = 15
# Get plot data
p <- dca(
MCS ~ Rt + SE + Os + model_logistic_full + model_logistic_RtSEOs + model_logistic_SEOs + model_mars,
data = dat_dca,
as_probability = c('Rt', 'SE', 'Os'),
label = list(
Rt = 'Rt',
SE = 'SE',
Os = "Os",
model_logistic_full = 'model_logistic_full',
model_logistic_RtSEOs = 'model_logistic_RtSEOs',
model_logistic_SEOs = 'model_logistic_SEOs',
model_mars = 'model_mars',
"Treat All" = "All",
"Treat None" = "None"
)) %>%
# plot DCA curves with ggplot
plot(smooth = TRUE, show_ggplot_code = T)
# De novo ggplot2
a <- p$data
as_tibble(a) %>%
dplyr::filter(!is.na(net_benefit)) %>%
ggplot(aes(x = threshold, y = net_benefit, color = label)) +
stat_smooth(method = "loess", se = FALSE, formula = "y ~ x",
span = 0.2, size = 2) +
coord_cartesian(ylim = c(-0.0305084745762712, 0.305084745762712
)) +
scale_x_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(x = "Threshold Probability", y = "Net Benefit", color = "") +
scale_color_manual(
breaks = c("Treat All", "Treat None", "Rt", "SE", "Os", "model_logistic_full", "model_logistic_RtSEOs", "model_logistic_SEOs", "model_mars"),
values = c('grey','black',mycolor[c(1,3,4,5,7,10,21)])
) +
theme_bw() +
theme(
axis.text = element_text(size = size/15*12,colour = "black",face = "bold"),
axis.title.x = element_text(size = size,colour = "black",face = "bold"),
axis.title.y = element_text(size = size,colour = "black",face = "bold"),
legend.text = element_text(size = size/15*12,colour = "black",face = "bold"),
legend.title = element_text(size = size/15*12,colour = "black",face = "bold"),
legend.position=c(0.8, 0.8),
# strip.background = element_rect(fill="white",size = 2),
# strip.text = element_text(size = size/15*12,colour = "black",face = "bold"),
panel.border = element_rect(colour = "black", linewidth = 2),
# panel.grid = element_blank(),
# panel.border=element_rect(fill='transparent',color='transparent'),
axis.ticks = element_line(colour = "black",linewidth = 2,linetype = 1,lineend = 'square')
# axis.line = element_line(colour = "black",size = 2,linetype = 1,lineend = 'square')
);
The plot is like:
Is it possible to change the linewidth of lines in DCA plot?
When I add
geom_line(size = 2)
, the result is misleading (add vs. not add):Any suggestions?