Wrong title when changing facet_col_wrap value

When I didnt’t set the facet_col_wrap, the titles are correct:

import plotly.express as px
import xarray as xr

# Load xarray from dataset included in the xarray tutorial
ds = xr.tutorial.open_dataset('eraint_uvz').sel(level=500)

data = ds.to_array().transpose('month', ...)
# fix the bug
#   TypeError: %d format: a real number is required, not str
plot_data = data.assign_coords({'variable': range(len(data['variable']))})
fig = px.imshow(plot_data, animation_frame='month',
                facet_col='variable', #facet_col_wrap=1,
                color_continuous_scale='viridis')

# set variable back to string
#   https://community.plotly.com/t/cant-set-strings-as-facet-col-in-px-imshow/60904
for k in range(len(data['variable'])):
    fig.layout.annotations[k].update(text = data['variable'].values[k])

fig.show()

However, if I set facet_col_wrap to one, the titles are wrong.

Note that if I didn’t modify the annotation manually, the titles are correct.

I checked the fig.layout.annotations list and found it is sorted by the order of y value.

Is this correct? I feel the order should be ascending for x and decending for y.

(layout.Annotation({
    'font': {},
    'showarrow': False,
    'text': 'variable=2',
    'x': 0.5,
    'xanchor': 'center',
    'xref': 'paper',
    'y': 0.2866666666666666,
    'yanchor': 'bottom',
    'yref': 'paper'
}), layout.Annotation({
    'font': {},
    'showarrow': False,
    'text': 'variable=1',
    'x': 0.5,
    'xanchor': 'center',
    'xref': 'paper',
    'y': 0.6433333333333333,
    'yanchor': 'bottom',
    'yref': 'paper'
}), layout.Annotation({
    'font': {},
    'showarrow': False,
    'text': 'variable=0',
    'x': 0.5,
    'xanchor': 'center',
    'xref': 'paper',
    'y': 0.9999999999999999,
    'yanchor': 'bottom',
    'yref': 'paper'
}))

If I understand correctly, it’s because start_cell is from bottom-left.

See the GitHub discussion.