I need to create a complex legend, which includes a fraction and the numerator and denominator are in different colors
.
Is it possible to create such a legend with (base) R?
Since I have to add this legend in several plots different plots, I do not want to manually program the text, but be able to add it automatically as the legend. It does not necessary have to be a legend (although it would be convenient), however I don’t want to have to manually enter the coordinates of each element.
Any ideas?!
Assuming that you have something like:
and you wouldn’t need different colors for numerator and denominator, you could do this with one-liner (including text location hint by @CarlWitthoft):
but there is no straightforward way to change colour of numerator and denominator. So the clunky way is to customize each element separately:
which I know is not what you really want, but just in case no better hack comes…