MattCowgill / ggannotate

Interactively annotate ggplots
Other
309 stars 20 forks source link

Add ggtext::geom_textbox option to insert the annotation #45

Open Edouard-Legoupil opened 2 years ago

Edouard-Legoupil commented 2 years ago

Great tool - thanks!!

Could be a nice improvement to add the option of getting the annotation R statement as ggtext::geom_textbox (together with related styling options...) as this would give a lot more options to style the annotation - ideally adding also the capacity to link the geom_textbox to the area of interest in the chart with a geom_curve arrows!

Currently did that manually - see example...

geom_curve(aes(xend = 10.9, yend = 2959.9, x = 6.9, y = 28668.7), size = 2, color = "tan", arrow = arrow(length = unit(0.07, "npc"))) + ggtext::geom_textbox(data = data.frame(x = 6.9, y = 28668.7, label = "Why so many people are using **other** category? \n Is there an important missing category ?"), mapping = aes(x = x, y = y, label = label), width = unit(0.6, "npc"), family = "Lato", size = 7, fill = "cornsilk", inherit.aes = FALSE)

MattCowgill commented 2 years ago

Thank you @Edouard-Legoupil, I'm glad you find the package useful.

I agree adding a ggtext::geom_textbox() option for an annotation layer would be good.

I see three options for this:

  1. Use ggtext::geom_textbox() for all text annotations;
  2. Offer a geom_textbox() option for an annotation (in the same way people can choose text / curve / etc)
  3. Detect whether the user has ggtext installed; if so, use geom_textbox(), if not use geom_text().

I guess I'm leaning towards (3) but would appreciate thoughts

Edouard-Legoupil commented 2 years ago

Hi @MattCowgill thanks for considering the suggestion! Indeed agreed (3) !!