pharmaverse / ggsurvfit

http://www.danieldsjoberg.com/ggsurvfit/
Other
70 stars 19 forks source link

Risk table fails to respect x-axis breaks when x-axis is duplicated #221

Open psoldath opened 2 months ago

psoldath commented 2 months ago

The risk table fails to respect the x-axis breaks when the x-axis is duplicated. Is this fixable? If so, I think it would be worthwhile to try and fix it as it would allow users to customize plots even further.

Risk table when x-axis is duplicated

library(ggsurvfit)

survfit2(Surv(time, status) ~ surg, data = df_colon) |> 
  ggsurvfit() +
  add_risktable() +
  scale_x_continuous(sec.axis = dup_axis())

Rplot

Fixing the problem would allow users to customize plots even further, such as....

library(ggplot2)

mpg |> 
  ggplot(aes(displ, hwy)) +
  geom_point() +
  scale_x_continuous(sec.axis = dup_axis(name = NULL, labels = NULL)) +
  scale_y_continuous(sec.axis = dup_axis(name = NULL, labels = NULL)) +
  theme_classic() +
  theme(axis.ticks.length = unit(-4, "pt"))

Rplot01