Plotting an NECDF file using xarray results in the correct orientation, but plotting it with Plotly Express causes it to be upside down

Plotting with ‘plotly.express’ is upside down. With xarray, it is plotting correctly. Is the problem with the file? I appreciate your help.

nc file here: BR-DWGD/exemplos/test_plotly.nc at main · AlexandreCandidoXavier/BR-DWGD · GitHub

import plotly.express as px
import xarray as xr
import plotly.io as pio
pio.renderers.default = "browser"

tmax = xr.open_mfdataset("test_plotly.nc")

# work correct
tmax['Tmax'].plot()

# does not work correct
fig = px.imshow(tmax['Tmax'], aspect='equal')
fig.show()

Results:

Screenshot from 2024-06-07 15-15-00

image

Hey @alexandre welcome to the forums.

Your data is fine, px.imshow() has this as it’s default behaviour. You can either use the origin parameter of px.imshow() or use go.Heatmap()

See also:

It’s working fine. Thanks!

1 Like