Support for `AsIs` variables
ggplot (at least starting from 3.5.0) improved functionality for specifying AsIs variables; that is, variables who do not participate in the scale systems at all and are interpreted literally.
For example, a column of literal colors can be specified (in R) as:
library(tidyverse)
my_colours <- sample(c("red", "green", "blue"), nrow(mpg), replace = TRUE)
ggplot(mpg, aes(displ, hwy)) +
geom_point(aes(colour = I(my_colours)))
and drawing text at the exact center of the plot (regardless of limits and scales) can be done as
ggplot(mpg, aes(displ, hwy)) +
geom_point(colour = "grey50") +
annotate(
"text",
label = "Text in the middle",
x = I(0.5), y = I(0.5),
size = 8
)
Does a similar API exist in plotnine? If not, I would love to have something like this - it would make placing text annotations on figures much, much easier. Thanks!
the scale_*_identity scales should allow you to do similar with regards to the colors.
I'm less certain about the panel-relative coordinates, I know some theme options take such values, but the annotations?
I saw this change, but I'm not sure whether we can do it in plotnine without quirky edge cases. I'll give it a shot for v0.16.0.
Related: #939
scale_*_identity does do what I want, but 1. There is no scale_{x,y}_identity, and 2. Using AsIs variables allows you to hae both literally interpreted and scaled variables in the plot - whereas using scale_*_identity forces you into only having literal variables along that scale.
Thanks for considering this feature; it's understandable if something like this is too hard to implement.