简体   繁体   中英

Setting the color bounds for a matplotlib streamplot

When I create a grid of streamplots (using subplot) they all have their own color bounds. There doesn't appear to be an option for manually setting the color bounds and hence I can't figure out how to make multiple streamplots share the same color bounds.

For example, my plot of the wind in the upper atmosphere uses the following code to create the streamplots:

magnitude = (u ** 2 + v ** 2) ** 0.5
ax.streamplot(x, y, u, v, color=magnitude)

The wind speed/magnitude during winter (JJA) is much stronger than during summer (DJF), however you don't get that impression from the plot because each subplot has its own individual color bounds.

Does anyone know of a solution to this problem?

You could use set_clim , which is similar to the caxis function in MATLAB. This normalizes the colormap to the specified range.

ax.set_clim(vmin=minvalue, vmax=maxvalue)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM