You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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!
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
Many thanks for your help :-)
Sabine
The text was updated successfully, but these errors were encountered: