Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pass-through of linejoin with geom_step #5705

Closed
heor-robyoung opened this issue Feb 23, 2024 · 1 comment · Fixed by #5706
Closed

Allow pass-through of linejoin with geom_step #5705

heor-robyoung opened this issue Feb 23, 2024 · 1 comment · Fixed by #5706
Labels
bug an unexpected problem or unintended behavior layers 📈
Milestone

Comments

@heor-robyoung
Copy link

When plotting Kaplan-Meier survival estimates or other stepwise estimates, there is an obvious radius applied to the outer corner of the linejoin at each step. This is visually misleading and causes issues with digitisation of the data after publication as the reader is dependent on a clear run-in and run-out of the line to establish the intersection point, as the midpoint of the diagonal across the corner cannot be used. This is not always possible on a "busy" plot with many censor marks, overlapping lines, or low overall resolution.

The ability to use mitre joins would allow for plots where the midpoint of the corner diagonal is a reliable indicator of the event time and resultant survival, allowing for more accurate digitisation of the plot data and reconstruction of the event times.

This information is highly valuable for indirect comparison of treatments, and uncertainty in relative efficacy of indirectly compared therapies is a major cause of reimbursement delay and thus access to treatment. Any improvement to publication standards that can be enabled by this change will have real-world impact on the availability of new treatments.

Reprex below clearly shows the radius on the stepwise function

library(ggplot2)
library(dplyr)

step_plot_data <- tribble(
  ~ls, ~x, ~y,
  1, 0, 1,
  1, 1, 0.75,
  1, 2, 0.5,
  1, 3, 0.5,
  2, 0, 0.5,
  2, 1, 0.25,
  2, 2, 0.0,
  2, 3, 0.0
)

p <- step_plot_data %>%
  ggplot(aes(x = x, y = y, colour = factor(ls), linewidth = ls))+
  geom_step()+
  scale_x_continuous("X", limits = c(-1, 4), breaks = seq(-1, 4, 1))+
  scale_y_continuous("Y", limits = c(0, 2), breaks = seq(0, 2, 0.25))+
  theme_light()

# Clearly visible at this resolution, particularly on the larger line
ggsave("test_plot_step.png",
       plot = p,
       width = 6,
       height = 4,
       dpi = 300,
       units = "in")
@teunbrand
Copy link
Collaborator

I think it may just have been a small oversight not to add these to geom_step(), so I'm considering the non-parity with geom_path() a bug rather than a feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior layers 📈
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants