thomasp85 / ggforce

Accelerating ggplot2
https://ggforce.data-imaginist.com
Other
916 stars 105 forks source link

Feature request: standalone geom_mark #281

Open adamkemberling opened 1 year ago

adamkemberling commented 1 year ago

Huge fan of the appearance and functionality behind the annotation style used in geom_mark_ellipse() and the other geoms that allow both a label and description, and would really like in some instances to be able to force where they appear, or use them without needing to reference datapoints you wish to mark.

This would be particularly helpful in cases when using multiple geom_mark_ellipse() lines to either highlight different subsets of data or when the data comes from different dataframes. Oftentimes these labels will overlay other data when employing filters and it would be good to have controls against that outside of building the descriptions into the dataframes themselves. Would also be helpful when standardizing placement for reproducible reporting.

Example use case highlighting the current implementation

library(ggplot2) library(ggforce)

ggplot(mtcars, aes(x = wt, y = mpg, col = factor(cyl))) + geom_point() + ggforce::geom_mark_ellipse(aes(filter = cyl == 4, label = cyl), description = "4 Cyllinders are okay") + ggforce::geom_mark_ellipse(aes(filter = cyl == 6, label = cyl), description = "6 Cyllinders are equally okay too")

image

Potential functionality

ggplot(mtcars, aes(x = wt, y = mpg, col = factor(cyl))) + geom_point() + ggforce::geom_mark_ellipse(aes(filter = cyl == 4, label = cyl), description = "4 Cyllinders are okay") + ggforce::geom_mark_text( con.x = 3.5, con.y = 28, label.x = 4, label.y = 32, label = "6" description = "I want my 6 cyllinder label over here, I don't care where my plot window thinks it should go")