Use mappable with scatter?


I’m creating a scatter plot and add a colorbar afterwards - this works fine.
However, there is one thing I don’t understand - for the scatter-plot I have to provide the way how a number is mapped to a color by 4 parameters (cmap, norm, vmin, vmax). However, the colorbar takes a ScalarMappable-object, that somehow contains the same information.

Is there a way to define a ScalarMappable-object once and use it for the scatter plot and the color bar? For me, this would make things easier to understand.


Can you please post your code? Usually scalarmappbles are created internal to the functions from Norm and Colormap objects created by the user, as described in