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 .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
^Makefile$
^CRAN-SUBMISSION$
^CLAUDE\.md$
^\.claude$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Meta
/doc/
/Meta/
/docs/
.claude
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 chart/risk table misalignment with ggplot2 >= 3.5.0 by using dynamic panel detection instead of hardcoded grob indices (#649, #675)
- Fix `ggcoxdiagnostics()` x-axis scaling when using `ox.scale = "time"` with Schoenfeld residuals (#608)
- 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
Expand Down
22 changes: 20 additions & 2 deletions R/ggsurvplot_core.R
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,30 @@ ggsurvplot_core <- function(fit, data = NULL, fun = NULL,
for (i in 1:length(plots)) {
if(is.ggplot(plots[[i]])){
grobs[[i]] <- ggplotGrob(plots[[i]])
widths[[i]] <- grobs[[i]]$widths[2:5]
# Find panel columns dynamically instead of hardcoding [2:5]
panel_cols <- which(grepl("panel", grobs[[i]]$layout$name))
if(length(panel_cols) == 0) {
# Fallback to traditional approach if no panel found
panel_range <- 2:min(5, ncol(grobs[[i]]))
} else {
# Use actual panel column range
panel_range <- min(panel_cols):max(panel_cols)
}
widths[[i]] <- grobs[[i]]$widths[panel_range]
}
}
maxwidth <- do.call(grid::unit.pmax, widths)
for (i in 1:length(grobs)) {
grobs[[i]]$widths[2:5] <- as.list(maxwidth)
if(!is.null(grobs[[i]])){
# Apply same panel range logic for setting widths
panel_cols <- which(grepl("panel", grobs[[i]]$layout$name))
if(length(panel_cols) == 0) {
panel_range <- 2:min(5, ncol(grobs[[i]]))
} else {
panel_range <- min(panel_cols):max(panel_cols)
}
grobs[[i]]$widths[panel_range] <- as.list(maxwidth)
}
}


Expand Down
Loading