X Tutup
Skip to content

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

@so-many-problems

Description

@so-many-problems

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup