I’m trying to visualize image-like data, so I’m using go.Image
. I would also like to have the y-axis going from negative in the bottom to positive in the top. However, it seems like the property autorange="reversed"
is not working. Is there a way to reverse it when plotting go.Image?
import plotly.graph_objects as go
import numpy as np
n1, n2 = 200, 100
x = np.linspace(-4, 5, n1)
y = np.linspace(-2, 1, n2)
xx, yy = np.meshgrid(x, y)
zz = np.zeros((*xx.shape, 3), dtype=int)
for i in range(n2):
for j in range(n1):
zz[i, j] = ((int((yy[i, j] - yy.min()) / (yy.max() - yy.min()) * 255)), 0, 0)
fig = go.Figure()
fig.add_trace(go.Image(
x0 = x.min(),
y0 = y.min(),
dx = (x.max() - x.min()) / n1,
dy = (y.max() - y.min()) / n2,
z=zz
))
fig.update_layout(
template = "plotly_dark",
yaxis = dict(
autorange = "reversed"
)
)
fig.show()