I'm trying to set the color limits in a basemap pcolormesh, in the same way that
matplotlib.pyplot.clim(-1, 1)
would set the colour minimum to -1 and maximum to 1. My code looks like this:
llcrnrlat = numpy.amin(gridLatLon['lat'])-0.5
urcrnrlat = numpy.amax(gridLatLon['lat'])+0.5
llcrnrlon = numpy.amin(gridLatLon['lon'])-0.5
urcrnrlon = numpy.amax(gridLatLon['lon'])+0.5
m = Basemap(projection='cyl', llcrnrlat=llcrnrlat,urcrnrlat=urcrnrlat,\
llcrnrlon=llcrnrlon,urcrnrlon=urcrnrlon,resolution='c')
y, x = m(gridLatLon['lat'], gridLatLon['lon'])
m.drawcoastlines()
m.drawcountries()
m.pcolormesh(x, y, efdata, latlon=True)
and it produces this, whereas I'm looking for the colours to be between -1 and 1, which would produce something like this (which I did using clim() but isn't on basemap).
Any and all suggestions as to how to improve my code are welcome.
Edit : gridLatLon
is a dictionary containing one field called lat
, which is a 2D numpy array of latitudes, and one field called lon
, a 2D numpy array of corresponding longitudes. I'm trying to plot efdata
, another 2D numpy array of the same size as the others.
As per matplotlib.pyplot.pcolormesh
m.pcolormesh(x, y, efdata, latlon=True, vmin=-1, vmax=1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With