Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

## Bug fixes

- Fix ggplot2 3.5.0 aesthetic length warning when using `surv.median.line = "hv"` or `"h"` with multiple survival curves (#643)
- Fix compatibility with ggplot2 development version (#681): Remove manual class assignment in `theme_survminer()` to ensure proper theme object construction
- Fix test suite compatibility with ggplot2 development version (#681): Update layer access syntax in tests to support both stable (`$layers`) and development (`@layers`) versions
- Fix "Ignoring unknown labels" warnings by conditionally setting legend titles only for aesthetics that are actually used in plots
Expand Down
9 changes: 6 additions & 3 deletions R/ggsurvplot_core.R
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,13 @@ ggsurvplot_core <- function(fit, data = NULL, fun = NULL,
df <- stats::na.omit(df)

if(nrow(df)>0){
if(type %in% c("hv", "h"))
if(type %in% c("hv", "h")){
# Create single-row dataframe for horizontal line to avoid aesthetic length warning
h_line_data <- data.frame(x = 0, y = max(df$y2), xend = max(df$x1), yend = max(df$y2))
p <- p +
geom_segment(aes(x = 0, y = max(y2), xend = max(x1), yend = max(y2)),
data = df, linetype = linetype, size = size, color = color) # horizontal segment
geom_segment(aes(x = x, y = y, xend = xend, yend = yend),
data = h_line_data, linetype = linetype, size = size, color = color) # horizontal segment
}

if(type %in% c("hv", "v"))
p <- p + geom_segment(aes(x = x1, y = y1, xend = x2, yend = y2), data = df,
Expand Down
2 changes: 1 addition & 1 deletion man/ggsurvtheme.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading