Skip to content

pvalue annotation placement is off-plot when the caption is a bit long #274

@DanChaltiel

Description

@DanChaltiel

Hi,

There is a slight misplacement of the pvalue annotation when the caption is a bit long:

library(ggsurvfit)
sf <- survfit2(Surv(time, status) ~ sex, data = df_lung)

sf %>%
  ggsurvfit() +
  add_pvalue(location="annotation", caption="Adjusted 2-sided Log-rank")
Image

Workaround:

(even better with hjust=1.05, vjust=2)

pval = survfit2_p(sf)
sf %>% 
  ggsurvfit() +
  annotate("text", x = Inf, y = Inf, hjust=1, vjust=1, 
           label = glue::glue("Log-rank adjusted 2-sided {pval}"))
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions