Plot map is not aligned with quiver

lats = nc.variables['latitude'][:]
lons = nc.variables['longitude'][:]
U=Data.eastward_wind[0]
V=Data.northward_wind[0]

plt.figure(constrained_layout=True)
plt.imshow(wspeed_var[0, 0, :, :], extent=[min(lons), max(lons), min(lats), max(lats)])
plt.quiver(lons[::2], lats[::2], U[::2, ::2], V[::2, ::2])
plt.ylabel('latitude')
plt.title('Global Wind Speed for for ' + datelabel.strftime('%Y-%b-%d %H:%M'))

The result I get is this:
mapresult

What I understand from the imshow result is that the map is generated from the top so because my lats list started with negative value it instead generated the value that should be at the bottom at the top instead. But why does the quiver is not affected by this?

It’s hard to tell if this is a Jupyter issue or an issue with the specific packages you are using. One way to determine it is Jupyter-specific would be to run your code as a script and show it works correct in an identical environment aside from Jupyter. If you determine it is not Jupyter causing the problem, you’d want to seek help in a more appropriate venue. Be sure to update this with that discussion or solution to help others following in you footsteps.
That being said…
You may get lucky & get someone here knowledgable in these modules who can help you though.

I would also add it is always better when asking for help to include a minimal reproducible example or point to the rest of your code. As it is here, you don’t include enough code for anyone to run this, even in Jupyter. For example, there’s no import statements.

2 Likes

My bad this issue was not caused by jupyter or any of the packages that i am using. I think the problem occur because I did not set up the extent correctly. Extent parameter is left, right, bottom, top but because my latitude data started with negative the top parameter should be negative and bottom param should be positive which make sense because the map is upside down. But in the code that i show you my bottom parameter is negative and my top is positive which cause my quiver to be display in a correct orientation. Both map and quiver align perfectly after i have changed the extent

1 Like