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.
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.
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.
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?
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 .
Activity
story645 commented on Oct 23, 2023
this looks pretty and also reasonable, but also this is pushing more in the direction of custom hatch #20690
pawjast commented on Oct 24, 2023
Yes, I can see it now. I didn't realize there's a similar request in the pipeline already.
story645 commented on Oct 24, 2023
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.
pawjast commented on Oct 24, 2023
How about "- " (dash/minus sign with a space)?
Or "_" (underscore)?
story645 commented on Oct 24, 2023
it won't work with our current parsing scheme, which allows infinite repetition of any character in the set '-+|/\xXoO.*'
matplotlib/lib/matplotlib/hatch.py
Lines 182 to 188 in b34e704
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?
ksunden commented on Oct 24, 2023
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)
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 .