ggsignif icon indicating copy to clipboard operation
ggsignif copied to clipboard

Manual vertical brackets do not work: "arguments imply differing number of rows"

Open bersbersbers opened this issue 3 years ago • 1 comments

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:

image

image

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

bersbersbers avatar Mar 05 '22 20:03 bersbersbers

Functionally related: kassambara/ggpubr#456

bersbersbers avatar Mar 05 '22 20:03 bersbersbers