Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 880
Damien Irving Avatar asked Dec 07 '25 21:12

Damien Irving


1 Answers

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)

like image 98
FTA Avatar answered Dec 09 '25 13:12

FTA



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!