Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Clip text when using clip_path in AGG#10811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ronnh wants to merge2 commits intomatplotlib:masterfromronnh:iss-8270-bugfix

Conversation

ronnh
Copy link

PR Summary

In response to issue#8270
Added a partial fix for when the text is not clipped.
When the text is being rendered, inside _backend_agg.h the draw_text_image function is not handling whether the text need to be clipped or not. Thus we added a condition to check. Currently if it needs to be clipped it will be rendered as an image.
Currently a clippath cannot be initialized together with the text because there is a separate where the clippath is not being passed properly.
With this fix a clippath can be added like this.

import numpy as npimport matplotlib as mplfrom matplotlib import pyplot as pltplt.figure(figsize=(8,8))ax = plt.gca()poly = mpl.patches.Polygon([[1,0], [0,1], [-1,0], [0,-1]],                            facecolor="#ddffdd", edgecolor="#00ff00", linewidth=2, alpha=0.5)ax.add_patch(poly)# add a text into the axes with clip path which should not be displayedtxt_outside = mpl.text.Text(0.65,0.85,"outside 1", clip_on=True, clip_path=poly)ax.add_artist(txt_outside)txt_outside.set_clip_path(poly)ax.set_xlim(-1,1)ax.set_ylim(-1,1)plt.show()

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymak
Copy link
Member

Thanks for the PR!

Can this get a descriptive title that does not refer to the issue number? But please refer to issue number in the text of the PR. You will get more reviewers if they know what this is about

@tacaswell
Copy link
Member

Does this mean that this clipping was working correctly with pdf / svg / eps / cairo backends?

Any idea what is going wrong with the tests? The "gw3] node down: Not properly terminated" warnings make me concerned that there is a segfault or similar introduced by this change.

Good job chasing this down to the Agg level!

@tacaswelltacaswell added this to thev3.0 milestoneMar 16, 2018
@phobsonphobson changed the titleIss 8270 bugfixClip text when using clip_path in AGGMar 17, 2018
@tacaswelltacaswell modified the milestones:v3.0,v3.1Jul 7, 2018
@jklymakjklymak modified the milestones:v3.1.0,v3.2.0Feb 8, 2019
@jklymak
Copy link
Member

@ronnh, are you planning to come back to this? It'll need a rebase, and will need to pass the tests.

@tacaswelltacaswell modified the milestones:v3.2.0,v3.3.0Aug 28, 2019
@QuLogic
Copy link
Member

I rebased this, and tried for quite a while to figure out why it was crashing, but right now I don't think this is quite the correct way to do it. It changes the type of the source image in the C code, but not the Python side. But doing that change on the Python side would be quite a far-reaching thing. This needs to be a bit more focused on the scanline rendering part, only.

Since this has not been touched for about 2 years and isn't working, I'm going to close this. Please re-open if you decide to come back to this.

@QuLogicQuLogic modified the milestones:v3.3.0,unassignedMay 12, 2020
@greglucasgreglucas mentioned this pull requestMar 4, 2023
2 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@ronnh@jklymak@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp