Skip to content

Support parallel line hatching at arbitrary angle and line density #20029

Open

Description

@joshmillard

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.

Activity

  1. github-actions commented on Dec 11, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  2. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions