Skip to content

Support hatching in cairo backends.#27856

Merged
QuLogic merged 1 commit intomatplotlib:mainfrom
anntzer:ch
Mar 15, 2024
Merged

Support hatching in cairo backends.#27856
QuLogic merged 1 commit intomatplotlib:mainfrom
anntzer:ch

Conversation

@anntzer
Copy link
Copy Markdown
Contributor

@anntzer anntzer commented Mar 4, 2024

Closes #363. Try e.g. plt.fill([0, 1, 0], hatch="/").

Direct transposition of the mplcairo implementation (except for the lack of proper stacking noted in the comments, which was already present for the alpha state so it's not really "worse"), itself translated from the agg implementation.

No tests, but adding tests for the cairo backend would be another adventure.

PR summary

PR checklist


def _set_rgba(ctx, color, alpha, forced_alpha):
if len(color) == 3 or forced_alpha:
ctx.set_source_rgba(*color, alpha)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the color is RGBA, then this could be incorrectly called with 5 arguments (RGBA color + alpha). The old code only used the first 3 elements of color. But perhaps that can never happen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, fixed. (We shoud really pin down what are the internal representations of colors at the renderer level, but that would be another project.)

Direct transposition of the mplcairo implementation (except for the lack
of proper stacking, which was already present for the alpha state so
it's not really "worse"), itself translated from the agg implementation.
Copy link
Copy Markdown
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to have worked in my testing.

@QuLogic QuLogic merged commit bcee01f into matplotlib:main Mar 15, 2024
@QuLogic QuLogic added this to the v3.9.0 milestone Mar 15, 2024
@anntzer anntzer deleted the ch branch March 15, 2024 09:41
@anntzer
Copy link
Copy Markdown
Contributor Author

anntzer commented Mar 15, 2024

I may just have gotten the new highscore for highest difference (in issue number or in time) between issue reported and closing PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable hatches for Cairo backend

3 participants