Search code examples
rggplot2annotations

Add two values in different rows in ggplot as text


I have this dataset: structure(list(new = c("No: 0.91", "Yes: 0.89", "All: 0.84")), row.names = c(NA, -3L), class = c("tbl_df", "tbl", "data.frame")) And I would like to create a plot with only the text like: enter image description here

But the text to be one below the other. So you have any idea?


Solution

  • One option would be to use nudge_y to shift the labels:

    library(ggplot2)
    
    ggplot() +
      geom_text(aes(
        x = 1, y = 1,
        label = c("No: 0.91", "Yes: 0.89", "All: 0.84")
      ), nudge_y = .05 * c(1, 0, -1))