ggsignif
ggsignif copied to clipboard
Manual vertical brackets do not work: "arguments imply differing number of rows"
I am trying to manually annotate a Kaplan-Meier-Plot with vertical significance brackets, and I am failing.
The reasons seems to be the orientation: the following horizontal example works fine, while the vertical does not print the brackets at all:


df <- data.frame(
x = 1:4, y = c(1, 1, 1, 5)
)
df_signif <- data.frame(
xmin = c(1, 3),
xmax = c(3, 4),
y_position = c(2, 6),
annotations = c("NS", "***")
)
ggplot(df, aes(x = x, y = y)) +
geom_point() +
ggsignif::geom_signif(
mapping = aes(
xmin = xmin,
xmax = xmax,
y_position = y_position,
annotations = annotations,
),
data = df_signif,
manual = TRUE,
)
ggplot(df, aes(x = y, y = x)) + # note the reversed coordinates!
geom_point() +
ggsignif::geom_signif(
mapping = aes(
xmin = xmin,
xmax = xmax,
y_position = y_position,
annotations = annotations,
),
data = df_signif,
manual = TRUE,
orientation = "y", # note the orientation!
)
Functionally related: kassambara/ggpubr#456