Colorbar limits in a Quiver plot

Hi!

I’m making a quiver and plotting its colorbar alongside it, like so:

FIG = figure()
AX1 = FIG.add_subplot(111)

QIV = AX1.quiver(X, Y, U, V, C)
FIG.colorbar(QIV)

The problem I’m facing is that depending the maximum of C, the scale on the colorbar keeps changing for different figures. Can I set a maximum value, so that I can then compare the colors on different figures?

I found the boundaries option, but that makes things discrete, and it doesn’t seem to change the colors in the quiver. How do I achieve what I want?

I just posted about boundaries making a colorbar discrete, if I understand your problem. See here:

https://discourse.matplotlib.org/t/displaying-colorbars-with-specified-boundaries-correctly/21177

In short, I think I have a general solution, but it requires changes to the colorbar code.

Try passing a long list of boundaries (for example, 1000 boundaries between 0 and C) and altering the tick properties. This will only work well if you wanted the boundaries to be evenly spaced before you made 1000 of them.

To get quivers in different plots to have the same colors at the same values, you’ll need to construct a Normalize object and pass it to each plot.

So I think I solved it using what you said last.

I just made a simple normalize object and passed it to quiver:

NORMZ = Normalize(vmin=0., vmax=0.3)
AX1.quiver(X, Y, U, V, C, norm=NORMZ)