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.
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).
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.
Activity
oscargus commented on Dec 21, 2022
Also relevant: #20690 and #21108 (as in the "proper" fix is probably to introduce a HatchStyle and then have a single validator).
anntzer commented on Jan 1, 2023
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).
story645 commented on Jan 1, 2023
why not do something like the marker API, where either pass a string that's currently valid or a 'HatchStyle' object?
anntzer commented on Jan 2, 2023
That won't work if you want to specify in your matplotlibrc a hatchstyle that'll be defined by a third-party library.
story645 commented on Apr 14, 2024
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.