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

**URL:** <https://community.plotly.com/t/plotting-an-necdf-file-using-xarray-results-in-the-correct-orientation-but-plotting-it-with-plotly-express-causes-it-to-be-upside-down/85023>\
**Category:** 📊 Plotly Python\
**Tags:** question\
**Created:** [June 7, 2024, 6:16pm UTC](https://community.plotly.com/t/plotting-an-necdf-file-using-xarray-results-in-the-correct-orientation-but-plotting-it-with-plotly-express-causes-it-to-be-upside-down/85023 "2024-06-07T18:16:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexandre](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@alexandre](https://community.plotly.com/u/alexandre)\
**Post date:** [June 7, 2024, 6:16pm UTC](https://community.plotly.com/t/plotting-an-necdf-file-using-xarray-results-in-the-correct-orientation-but-plotting-it-with-plotly-express-causes-it-to-be-upside-down/85023/1 "2024-06-07T18:16:56Z")

</div>

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](https://github.com/AlexandreCandidoXavier/BR-DWGD/blob/main/exemplos/test_plotly.nc)

```auto
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](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/4/4/44d398e90b3ad5245fa3b074e7e4637a76f768a8.png)

![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/0/a/0a619ca07104baf78606e0fe0554d4a55d26cbfb.png)

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [June 9, 2024, 5:37pm UTC](https://community.plotly.com/t/plotting-an-necdf-file-using-xarray-results-in-the-correct-orientation-but-plotting-it-with-plotly-express-causes-it-to-be-upside-down/85023/2 "2024-06-09T17:37:52Z")

</div>

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:

> [@Inverted image in go.Image vs go.Heatmap?](https://community.plotly.com/t/inverted-image-in-go-image-vs-go-heatmap/75935/2):
>
> Yes, go.Heatmap() inverts the y-axis. Instead of go.Heatmap() you could use px.imshow() which has the parameter origin which alters this behaviour. I don’t know rofl EDIT: Quite helpful SO post:

---

<div class="post-metadata">

**Author:** ![alexandre](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@alexandre](https://community.plotly.com/u/alexandre)\
**Post date:** [June 10, 2024, 4:47pm UTC](https://community.plotly.com/t/plotting-an-necdf-file-using-xarray-results-in-the-correct-orientation-but-plotting-it-with-plotly-express-causes-it-to-be-upside-down/85023/3 "2024-06-10T16:47:40Z")

</div>

It’s working fine. Thanks!
