Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quiver plot in polar projection - how to make the quiver density latitude-dependent ? #6056

Closed
so-many-problems opened this issue Feb 24, 2016 · 2 comments

Comments

@so-many-problems
Copy link

Hello,

I want to do a quiver plot on a polar basemap plot. I have a regular lat/lon grid, and because there are more grid boxes at the higher latitudes, my code plots as many quivers at the pole as on the equator, so they overlap etc. How can I make the density of quivers latitude-dependent?

This is the code I use

import numpy as np
from mpl_toolkits.basemap import Basemap, addcyclic
import matplotlib.pyplot as plt


m_mu = Basemap(projection='npstere',boundinglat=10,lon_0=0,resolution='l',round=True)

lats=np.arange(0.,91.,15.)
lons=np.arange(-180.,181.,30.)
valin_u=np.array([[np.random.randn() for y in range(len(lons))] for x in range(len(lats))])
valin_v=np.array([[np.random.randn() for y in range(len(lons))] for x in range(len(lats))])
del x,y

valin = np.sqrt( valin_u**2 + valin_v**2 )

mu_cyclic, lons_cyclic = addcyclic(valin, lons)
mu_cyclic_u, lons_cyclic = addcyclic(valin_u, lons)
mu_cyclic_v, lons_cyclic = addcyclic(valin_v, lons)

grid = np.meshgrid( lons_cyclic, lats )
x, y = m_mu( *grid)

plt.figure()
cs = m_mu.pcolormesh(x, y, mu_cyclic)
#csquiv = m_mu.quiver(x[::3,::3], y[::3,::3], mu_cyclic_u[::3,::3], mu_cyclic_v[::3,::3])
csquiv = m_mu.quiver(x[::1,::1], y[::1,::1], mu_cyclic_u[::1,::1], mu_cyclic_v[::1,::1])
plt.show()

Many thanks for your help :-)
Sabine

polar_quiver_plot

@so-many-problems
Copy link
Author

oh no, just realised that maybe this isn't the right place to pose this question? have posted in on stack exchange but dont find where to delete this - sorry!

@tacaswell
Copy link
Member

Can not delete, just close.

I will close this, re-open if you think you have found a bug.

the mailing list matplotilb-users@python.org is also a good place to ask "how do I..." questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants