Issue
Anyone knows why this ocurrs in colobar ticks? How to fix it?
The code:
ax = plt.axes(projection=ccrs.PlateCarree())
cf3 = ax.streamplot(u.longitude, u.latitude, u.isel(valid_time=index).data,
v.isel(valid_time=index).data, linewidth=0.5, cmap=plt.cm.jet,
arrowsize=1.5, density=5, color=mag, transform=ccrs.PlateCarree())
axins = inset_axes(ax, width="95%", height="2%", loc='lower center', borderpad=-3.6)
bar = fig.colorbar(cf3.lines, cax=axins, orientation='horizontal', extendrect=True, label='Velocidade [m/s]')
cbar.set_ticks(ticks=[0,5,10,15,25,30])
Solution
With the limited code provided, I think passing the 'norm' argument to ax.streamplot() could solve your issue. First you need to create a normalized object using:
import matplotlib as mpl
normalize = mpl.colors.Normalize(vmin, vmax)
Where 'vmin' and 'vmax' correspond to your desired upper and lower limits of the values used for the colorbar.
For example:
normalize = mpl.colors.Normalize(0, 40)
cf3 = ax.streamplot(u.longitude, u.latitude, u.isel(valid_time=index).data,
v.isel(valid_time=index).data, linewidth=0.5, cmap=plt.cm.jet,
arrowsize=1.5, density=5, color=mag, transform=ccrs.PlateCarree(),norm=normalize)
should limit your colorbar values between 0 and 40, leading to identical colorbars between iterations of your streamplots.
Answered By - Spencejo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.