I'd like to visualize a 20x20 matrix, where top left point is (-10, 9) and lower right point is (9, -10). So the x is increasing from left to right and y is decreasing from top to bottom. So my idea was to pass x labels as a list: [-10, -9 ... 9, 9] and y labels as [9, 8 ... -9, -10]. This worked as intended in seaborn (matplotlib), however doing so in plotly just reverses the image vertically. Here's the code:
import numpy as np
import plotly.express as px
img = np.arange(20**2).reshape((20, 20))
fig = px.imshow(img,
x=list(range(-10, 10)),
y=list(range(-10, 10)),
)
fig.show()
import numpy as np
import plotly.express as px
img = np.arange(20**2).reshape((20, 20))
fig = px.imshow(img,
x=list(range(-10, 10)),
y=list(reversed(range(-10, 10))),
)
fig.show()
Why is this happening and how can I fix it?
EDIT: Adding seaborn code to see the difference. As you can see, reversing the range for labels only changes the labels and has no effect on the image whatsoever, this is the effect I want in plotly.
import seaborn as sns
import numpy as np
img = np.arange(20**2).reshape((20, 20))
sns.heatmap(img,
xticklabels=list(range(-10, 10)),
yticklabels=list(range(-10, 10))
)
import seaborn as sns
import numpy as np
img = np.arange(20**2).reshape((20, 20))
sns.heatmap(img,
xticklabels=list(range(-10, 10)),
yticklabels=list(reversed(range(-10, 10)))
)