 # Multiple quiver subplots under the same colormap scale

Hi,
I am trying to draw two quiver plots which compare two different cases side by side.
To clearly show the difference, I’d like to apply the same colormap scale to two subplots.
Usually, the use of quiver plot is as follows:

colormap = plt.cm.coolwarm
fig, axe = plt.subplots(1, 2, squeeze=False)
q1 = axe[0,0].quiver(x_pos1, y_pos1 ,u1, v1, c_array1, cmap=colormap)
q2 = axe[0,1].quiver(x_pos2, y_pos2 ,u2, v2, c_array2, cmap=colormap)

However, I think quiver plot automatically normalizes the color array, and there is no option to use vmin and vmax like imshow or contour plot.
Is there an easy way to limit the range of colormap?
Currently as a temporary solution, I made an extended meshgrid, a part of which is not shown in the final plot by limiting axes range and then put the same maximum values in the not shown grid part of c_array1 and c_array2 to unify the color scale.

1 Like

quiver takes a `norm` kwarg, so you can explicitly set the scale that way:

``````import matplotlib.colors as mcolors
norm = mcolors.Normalize(vmin = min_value, vmax = max_value)

colormap = plt.cm.coolwarm
subplots(1, 2, squeeze=False)
# here is the addition of the norm keyword argument:
q1 = axe[0,0].quiver(x_pos1, y_pos1 ,u1, v1, c_array1, cmap=colormap, norm=norm)
q2 = axe[0,1].quiver(x_pos2, y_pos2 ,u2, v2, c_array2, cmap=colormap, norm=norm)
``````

If you’d like a more detailed explanation on normalization, there is a tutorial on colormap normalization

1 Like

Thank you very much!