Visitar URL original
Define additional/custom hatches · Issue #20690 · matplotlib/matplotlib · GitHub
The Wayback Machine - https://web.archive.org/web/20210813222241/https://github.com/matplotlib/matplotlib/issues/20690
Skip to content
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

Define additional/custom hatches #20690

Open
mtb-za opened this issue Jul 20, 2021 · 7 comments
Open

Define additional/custom hatches #20690

mtb-za opened this issue Jul 20, 2021 · 7 comments
Milestone

Comments

@mtb-za
Copy link

@mtb-za mtb-za commented Jul 20, 2021

Problem

The current set of hatching options within matplotlib is somewhat limited, being only the following, with the ability to make more dense ones.
image
In geoscience (and possibly other fields, but that is my background) there are a number of other hatching patterns that have long historical use and are still common, cf the USGS templates, available as a pdf here. Some of these are complex enough to be difficult to generate programmatically (eg 706: contorted schist), while others are much simpler (eg 328-K, which is a grid of offset +).

Is there a means to safely define hatches such the latter? A workaround, adding custom hatches to _hatch_types can be done but raises a deprecation warning (MatplotlibDeprecationWarning: hatch must consist of a string of "*+-./OX\ox|" or None, but found the following invalid values "p". Passing invalid values is deprecated since 3.4 and will become an error two minor releases later.) since PR #17926, and is therefore not a stable long-term solution.

Proposed Solution

It would be good to have a means to define custom hatches in a safe way. In many cases I think it likely to be package maintainers adding the functionality (as striplog does) rather than users.

A less comprehensive solution that would still cover many common use-cases would be to allow for repetitive hatching of a single (user-chosen) symbol. (That is, being able to place a regular grid of + or L in the way that the current hatches API handles cases like . and o.)

Additional context and prior art

@jklymak
Copy link
Contributor

@jklymak jklymak commented Jul 20, 2021

I don't think there would be a problem adding a public interface to add a patch pattern. I think the largest issue would be documenting it. But if it was clear it was an advanced feature I don't imagine there would be a problem if you wanted to open a PR.

@mtb-za
Copy link
Author

@mtb-za mtb-za commented Jul 21, 2021

Thanks for the encouragement. I will have a think about how the API might look, and see if I can make something sensible for a PR.

@story645
Copy link
Member

@story645 story645 commented Jul 22, 2021

@mtb-za you can always start w/ a really rough PR and ask us to mark it as a draft if you wanna publicly hash it out.

@dopplershift
Copy link
Contributor

@dopplershift dopplershift commented Jul 22, 2021

You can also create a draft PR yourself by clicking the arrow to the right of the green "Create Pull Request" button (when submitting the PR) and selecting "Create draft pull request":
image

@tacaswell tacaswell added this to the v3.6.0 milestone Jul 23, 2021
@tacaswell
Copy link
Member

@tacaswell tacaswell commented Jul 23, 2021

This is something we proposed in the most recent CZI proposal so it is reassuring to get further confirmation of user need :)

In the discussion around that @QuLogic said that any tiling path should be able to be used as a hatch (including contorted schist).

@QuLogic
Copy link
Member

@QuLogic QuLogic commented Jul 27, 2021

Yes, theoretically it should be possible, but might need to do a bit of low-level surgery to expose it.

@MosGeo
Copy link

@MosGeo MosGeo commented Jul 27, 2021

In addition to striplog, I believe projects like Cartopy will benefit greatly from this once geologic standards (e.g., https://github.com/cecgeology/USGS-FGDC) are implemented as matplotlib custom hatches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants