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

Addrasterized option tocontourf#29582

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

Merged
rcomer merged 8 commits intomatplotlib:mainfromAdamOrmondroyd:rasterizecontourf
Mar 18, 2025

Conversation

AdamOrmondroyd
Copy link
Contributor

@AdamOrmondroydAdamOrmondroyd commentedFeb 5, 2025
edited
Loading

PR summary

Hi, this is my first PR to matplotlib!

Therasterization documentation suggests one can addrasterized=True tocontourf, similar topcolormesh. This doesn't do anything besides warn the user thekwarg hasn't been used. Setting the resultingQuadContourSet to rasterised causes another warning, but seems to work fine.#27669 picks up on this.

This PR addresses both issues, still need to add tests.

importmatplotlib.pyplotaspltimportnumpyasnpx=y=np.arange(-3.0,3.01,delta)X,Y=np.meshgrid(x,y)Z=np.exp(-X**2-Y**2)fig,ax=plt.subplots(layout='constrained')CS=ax.contourf(X,Y,Z,10,rasterized=True)# currently causes UserWarning: The following kwargs were not used by contour: 'rasterized'# result isn't rasterized# orCS=plt.contourf(X,Y,Z,10)CS.set_rasterized(True)# currently causes UserWarning: Rasterization of '<matplotlib.contour.QuadContourSet object at 0x10304e3c0>' will be ignored# result is rasterizedfig.savefig('foo.pdf')

(screenshot of) unrasterized foo.pdf
Screenshot 2025-02-05 at 19 16 54
(screenshot of) rasterized foo.pdf
Screenshot 2025-02-05 at 19 15 38

Closes#27669

PR checklist

htjb reacted with hooray emoji
Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@AdamOrmondroyd
Copy link
ContributorAuthor

I've had a good look and can't see where the test for this would naturally fit in

@AdamOrmondroydAdamOrmondroyd marked this pull request as ready for reviewFebruary 9, 2025 14:29
Copy link
Member

@rcomerrcomer left a comment

Choose a reason for hiding this comment

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

Thanks@AdamOrmondroyd and sorry you didn't get a response sooner. I thinktest_contour.py would be a reasonable place to add a test.

@rcomerrcomer moved this fromNeeds review toWaiting for author inFirst Time ContributorsMar 3, 2025
@tacaswelltacaswell added this to thev3.11.0 milestoneMar 17, 2025
@tacaswell
Copy link
Member

I agree on both apologizing that this did not get attention earlier and adding a baseline image.

It is a surprising oversight that this has been missing!

@AdamOrmondroyd
Copy link
ContributorAuthor

Seems to work (screenshot of contour_rasterization.pdf with dpi set to 25dpi)

Screenshot 2025-03-17 at 10 10 16

What tolerance is appropriate forimage_comparison?

jklymak reacted with thumbs up emoji

@rcomer
Copy link
Member

Usually leaving the tolerance to default is fine. Sometimes it needs to be a little higher to accommodate slightly different results on different platforms. So you can just wait to see if CI passes.

jklymak reacted with thumbs up emoji

Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

Looks good thanks!

@AdamOrmondroyd
Copy link
ContributorAuthor

do I need access? I don't have a merge button

@rcomerrcomer merged commit73d28ee intomatplotlib:mainMar 18, 2025
41 checks passed
@rcomer
Copy link
Member

do I need access? I don't have a merge button

No, we just require two approving reviews before merging code changes.

Thanks for your work on this@AdamOrmondroyd and congratulations on your first Matplotlib PR! We hope to hear from you again.

AdamOrmondroyd reacted with thumbs up emoji

@QuLogicQuLogic moved this fromWaiting for author toMerged inFirst Time ContributorsMar 18, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@jklymakjklymakjklymak approved these changes

@rcomerrcomerrcomer approved these changes

Assignees
No one assigned
Projects
Milestone
v3.11.0
Development

Successfully merging this pull request may close these issues.

[Doc]: documentation of how to properly rasterize output of contourf
4 participants
@AdamOrmondroyd@tacaswell@rcomer@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp