Damien Irving
Damien Irving

Reputation: 377

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?

Upvotes: 3

Views: 1552

Answers (1)

FTA
FTA

Reputation: 345

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)

Upvotes: 2

Related Questions