4 thoughts on “Feature Request: manually set colorbar without mappable

  1. Having a common colorbar for multiple axes is part of what I was looking for, but what I’d really like is the ability to explicitly set the limits of the colorbar via arguments to the colorbar method.

  2. Close if you want to — but just to clarify:

    The point of the original issue was to request that the interface be simplified. Yes, there are ways to create a colorbar on e.g. line plots:

    sm = plt.cm.ScalarMappable(cmap=my_cmap, norm=plt.Normalize(vmin=0, vmax=1))
    sm._A = []

    But this isn’t intuitive/easy for users — you more or less need to go to stackoverflow or dig deep into the documentation/examples to figure this out. So the proposal/feature request was to make this a one-liner and have matplotlib execute something like the above code under the hood (without the user needing to know what a ScalarMappable is).

  3. Well my use case was an animation where the lines were changing color over time. For example, representing flow in a network, or electricity.

    I wanted a colorbar on the side to show the range of the colormap I was using. So, for example, if the maximum flow allowable was 1.0, it would be nice to just specify:


    Edit: Also, while the LineCollection example is a nice one, it isn’t immediately obvious to the common user that it exists and how to take advantage of it. Whereas I think the above one-liner is likely something people would try off the bat (especially if the min/max options are listed in the documentation for colorbar).

Comments are closed.