How to color ggforce::geom_mark_ellipse labels with fill color

Viewed 694

Is it currently possible to make the labels generated with ggforce::geom_mark_ellipse(label=) colored?

In the example below, I'd like to see versicolor typeface in green:

1 Answers

Yes, but not in a straightforward way like you would with any other mapped aesthetics. You would have to build a new layer where you change the colour and filter the layers correctly. You can see this becoming quite laborious if you have 10+ groups each needing their own label colour.

library(ggplot2)
library(ggforce)

ggplot(iris, aes(Petal.Length, Petal.Width)) +
  geom_mark_ellipse(aes(fill = Species, label = Species,
                        filter = Species != 'versicolor')) +
  geom_mark_ellipse(aes(fill = Species, label = Species,
                        filter = Species == 'versicolor'),
                    label.colour = "green") +
  geom_point()

enter image description here

Related