Skip to content

Allow pass-through of linejoin with geom_step #5705

Closed
@heor-robyoung

Description

@heor-robyoung

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorlayers 📈

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions