【发布时间】:2022-12-01 12:49:25
【问题描述】:
I'd like to visualize a 20x20 matrix, where top left point is (-10, 9) and lower right point is (10, -9). 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?
【问题讨论】:
标签: python plotly plotly-python