Description
Problem
Now that Norms are auto-derived from Scales (see make_norm_from_scale
), it may be nice to reuse the scale-name machinery to allow using strings to specify norms, e.g.
imshow(..., norm="log")
# => norm=colors.make_norm_from_scale(scale.scale_factory("log"))
# a.k.a. norm=colors.LogNorm()
and perhaps
imshow(..., norm=("log", vmin, vmax))
or just allow
imshow(..., norm="log", vmin=vmin, vmax=vmax)
(#15769 deprecated norm=LogNorm(), vmin=vmin, vmax=vmax
but that was because in that case it was unclear whether the passed-in norm should be mutated, whereas here it's always a new norm instance which can thus always be mutated). (I'm not always particularly fond of using strings when objects would be more featureful, but here the machinery for scales is already present and well established so...)
This would seem relatively easy to implement, except for one detail: LogScale currently defaults to nonpositive="clip"
(see #9477 and the long tree of linked issues for the reason), whereas norms use nonpositive="mask"
(which is more or less implied by the existence of APIs like Colormap.set_bad
). While this can be resolved in an ad-hoc manner (e.g. by making sure that such scales have a nonpositive
parameter/attribute and setting it accordingly), I wonder whether a more general solution is possible.
Proposed Solution
As described above.
Additional context and prior art
AFAICT, proplot uses a hard-coded mapping of norm names (https://proplot.readthedocs.io/en/latest/api/proplot.constructor.Norm.html).