knitr::opts_chunk$set(echo = TRUE) library(tidyverse) library(ggtext)
#set up lines as a dataframe lines_df <- tribble(~x, ~y, ~xend, ~yend, 4,5,21,22, 4,2,24,2, 24,2,24,22, 2,5,2,25, 2,25,21,25)
consider doing geom_rect instead to control width, height, and position then use geom_text for text set up boxes as a dataframe
boxes_df <- tribble(~x, ~y, ~label, ~w, 2,2,"Text in the<br>Lower Left", 0.01, 21,22,"Text in the<br>Upper Right", 0.06)
ggplot(boxes_df) + geom_textbox(aes(x = x, y = y, label = label, width = unit(w, "native"), hjust = 0, vjust = 0, # location point at lower left of box halign = 0.5, valign = 0.5), box.r=unit(0, "pt"), box.padding = unit(c(2, 4, 4, 4), "pt"), height = unit(0.12, "native")) + geom_segment(data = lines_df, aes(x=x, y=y, xend=xend, yend=yend), lineend = "round", linejoin = "round", arrow = arrow(length = unit(0.3, "cm"), ends = "last", type = "closed"), arrow.fill = "black")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.