Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Problem
While matplotlib currently provides a degree of hatch fill functionality with set_hatch, fine control of the angle and density of hatch lines isn't straightforward. The current functionality only directly allows the parallel hatch lines at horizontal, vertical, or 45 degree diagonal orientations, and the density of those lines is expressed implicitly by strings of repeating symbols (e.g. "/" for a sparse diagonal hatch, "///" for a more dense one, etc).
Hatch patterns are also currently tied to the shape they're filling, whereas an independent collection of lines would be more flexible for further graphical manipulation.
Proposed Solution
My suggestion is a distinct method for generating a hatch of parallel lines, based on a target shape, accepting numeric angle and density values. I'm imagining this functioning as something like another item in the matplotlib.patches family, invoked along the lines of
matplotlib.patches.Hatch(bounding_polygon, angle, size)
where bounding_polygon is e.g. a Polygon patch, angle is the orientation angle to which the hatch lines run parallel, and size is a gap between each hatch line along the axis perpendicular to the orientation angle.
The result would be a new patch object consisting of some number of line segments that effectively fill the original shape's interior area with hatching lines but which exists as its own independent patch.