FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[ENH]: dashed hatching pattern · Issue #27170 · matplotlib/matplotlib · GitHub

Repository navigation

[ENH]: dashed hatching pattern  #27170

Open

Description

Problem

I've recently seen a plot with a dashed hatching style and was wondering if there's a case for adding such a style to matplotlib? Especially that we've got dotted hatching already available and this seems to be similar.

Source: https://twitter.com/DataVizStefan/status/1714930118781530248/photo/1

Proposed solution

I don't have the exact solution but matplotlib allows to create all sorts of fancy edge line styles so I'd imagine the technical ability of the library to implement this request is there.

https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html

Activity

  1. story645 commented on Oct 23, 2023

    Member

    this looks pretty and also reasonable, but also this is pushing more in the direction of custom hatch #20690

  2. pawjast commented on Oct 24, 2023

    Author

    Yes, I can see it now. I didn't realize there's a similar request in the pipeline already.

  3. story645 commented on Oct 24, 2023

    Member

    Both? I think this in particular is clear enough that it could be an out of the box style, but I have no idea what the unambiguous short notation would be since -- is a more dense horizontal line.

  4. pawjast commented on Oct 24, 2023

    Author

    How about "- " (dash/minus sign with a space)?
    Or "_" (underscore)?

  5. story645 commented on Oct 24, 2023

    Member

    How about "- " (dash/minus sign with a space)?

    it won't work with our current parsing scheme, which allows infinite repetition of any character in the set '-+|/\xXoO.*'

    def _validate_hatch_pattern(hatch):
    valid_hatch_patterns = set(r'-+|/\xXoO.*')
    if hatch is not None:
    invalids = set(hatch).difference(valid_hatch_patterns)
    if invalids:
    valid = ''.join(sorted(valid_hatch_patterns))
    invalids = ''.join(sorted(invalids))

    but now I'm thinking this would also be nice in vertical and diagonal and thinking that "DashedHatch" might be a good place to prototype a custom hatch object since it's scoped pretty clean? Using any of the classes specified in https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/hatch.py#L14 as a model?

  6. ksunden commented on Oct 24, 2023

    Member

    Any two character sequence is tough, and any sequence that includes an extant character is even tougher, as hatch patterns use repetitions to increase density, and do so irrespective of their ordering, etc. (They just do pattern.count("-")) Retaining desired behavior while allowing for multichar sequences is likely to cause confusion.

    I think _ could work, could also argue for =, though I think that would imply a slightly different mark.

    I do think that some of the finer points of the example above may be challenging without a more extensive refactor of hatching (which isn't to say not its not worthwhile, but is to say it may be a larger task than originally expected)

    • The fact that the first dash in a line looks to be following the contour of the region rather than being on a fixed grid
      • Lines in the lower section are stacked on top of one another, while lines in the upper section are staggered, but not by any particular pattern.
    • That density seems to equate to shorter lines is a bit of a wrinkle (though I think this could be done in current frameworks)

    I agree that the example looks nice and if we could capture that it would be good, I just expect that what we would implement now would be potentially more rigid looking:

    e.g. here is what I got by just hacking the dash pattern in the svg backend (not threading it through anywhere, etc, just was trying to get an idea, was using the branch from #27158 as my starting point because the example there is analogous to the example here in a way):

    Note how all the dashes/gaps are aligned vertically.. I suspect that many of the "easy" ways to implement this idea will have that in common. I'm less concerned with the fact that this example does not scale the lines/gaps inversely to density, I think that is relatively easy to do .

  7. linked a pull request that will close this issueadded dashed hatch pattern #28072on May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL