简体   繁体   English

设置matplotlib流图的颜色范围

[英]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. 冬季(JJA)的风速/幅值比夏季(DJF)的强得多,但是由于每个子图都有自己的颜色范围,因此您不会从图中得到印象。

Does anyone know of a solution to this problem? 有谁知道解决这个问题的方法吗?

You could use set_clim , which is similar to the caxis function in MATLAB. 您可以使用set_clim ,它类似于MATLAB中的caxis函数。 This normalizes the colormap to the specified range. 这会将色图标准化为指定范围。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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