-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[MNT]: de-duplicate hatch validation #24797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Assuming we want to allow custom hatches at some point (which seems to be the general agreement in #20690, and I tend to agree as well), the practical solution may just be to get rid of validate_hatch and allow any string in rcParams (possibly later exploding at runtime), just like we allow any string for image.cmap (and not just known colormap names) as the corresponding colormap may well not be registered yet (e.g. if reading from matplotlibrc and registering the colormap at runtime). |
why not do something like the marker API, where either pass a string that's currently valid or a 'HatchStyle' object? |
That won't work if you want to specify in your matplotlibrc a hatchstyle that'll be defined by a third-party library. |
I don't know if anyone's opened an issue for this, but on one of the calls we've discussed the idea of having a registry system for hatches, kinda like how we do for colormaps? Which I think ties into your suggestion on how we do validation like we do for cmap. |
Summary
In #17926 code to validate hatches got added to the hatch module:
matplotlib/lib/matplotlib/hatch.py
Lines 182 to 196 in 5100378
and there's near identical code in rc validation that went in in #4686:
matplotlib/lib/matplotlib/rcsetup.py
Lines 580 to 592 in 5093150
They diverge slightly in that the hatch version has a deprecation warning but I think it should also apply to the rc version?
Proposed fix
Make the validation function in hatch.py the canonical validator and either deprecate the rcsetup validation function or turn it into a thin shim over the one in hatch.
The text was updated successfully, but these errors were encountered: