Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Problem
Now that Norms are auto-derived from Scales (seemake_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 deprecatednorm=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 tononpositive="clip"
(see#9477 and the long tree of linked issues for the reason), whereas norms usenonpositive="mask"
(which is more or less implied by the existence of APIs likeColormap.set_bad
). While this can be resolved in an ad-hoc manner (e.g. by making sure that such scales have anonpositive
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).