Suppose I want to make a subplot like this in which each facet has its own y scale:
import plotly.express as px
fig = px.scatter(px.data.iris(), x='sepal_length', y='sepal_width', facet_col='species')
def update(y):
y.update(matches=None)
y.showticklabels=True
fig.for_each_yaxis(update)
Now suppose I want to add some annotations, and the position is going to vary according to the faceted variable, and I have this in a dataframe:
If I was using plotnine/ggplot I could do it like this:
ggplot(df_iris, aes(x='sepal_length', y='sepal_width')) + geom_point() + facet_wrap("~species", scales="free_y") + geom_text(aes(x='x', y='y', label='label'), data=df_text)
Is it possible to do this in plotly? I got pretty bogged down mucking around with subplots and annotations, I know you can add annotations to a subplot, but you have to know the row and column number in order to do that, and I'm not sure how I can map the facet variable (species) to the subplot row/column indexes.
Thanks :)