0

This is likely a very silly question but I can't seem to find anything online in regards to creating a plot in RStudio but the plot only having text. I am trying to generate a plot via RStudio that simulates the attached photo. I believe ggplot is the right package to use but I cannot get the plot to be text only unless I actually have a graph. Can anyone help??

I want a R generated plot to look similar to this

stefan
  • 90,330
  • 6
  • 25
  • 51

1 Answers1

2

Not sure what you tried but could make a text only chart as easy as other charts using e.g. geom_text or what seems more appropriate to your desired result using ggtext::geom_textbox:

library(ggplot2)
library(ggtext)

df <- data.frame(
  x = 1, y = 1, 
                 label = paste(
                   "<span style='color: red; font-size: 100pt'>1 in 6</span>",
                   "<span style='color: black; font-size: 20pt'>people admitted to cheating on their partner</span>", sep = "<br>"))

ggplot(df) +
  ggtext::geom_textbox(aes(x = x, y = y, label = label), box.colour = NA, width = unit(10, "cm")) +
  theme_void()

stefan
  • 90,330
  • 6
  • 25
  • 51
  • Thank you Stefan, it worked! I can't upvote your comment because I dont have enough reputation but I appreciate it heaps! – kingjezza45 May 19 '22 at 04:19