Skip to content

Conversation

@anntzer
Copy link
Contributor

@anntzer anntzer commented Dec 13, 2025

Most fixes are self-explanatory. The change to the flask command-line allows using the same instructions on all OSes. The one to the CanvasAgg example is there because it is no longer (since mpl3.1) necessary to explicitly attach the canvas in the savefig() case.

PR summary

PR checklist

@github-actions github-actions bot added topic: pyplot API Documentation: examples files in galleries/examples Documentation: user guide files in galleries/users_explain or doc/users labels Dec 13, 2025

# Option 2: Retrieve a memoryview on the renderer buffer, and convert it to a
# numpy array.
# Option 2: Manually attach a canvas to the figure (pyplot or savefig would
Copy link
Member

Choose a reason for hiding this comment

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

When is this better than the fig.savefig approach? It feels a bit too low-level. Is this for cases where you want the image as numpy array with as little overhead as possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You get to skip the encoding to png and decoding. Admittedly I doubt that it's that costly at all, but I didn't want to change the whole structure of the example either (and I guess it's also useful to showcase these internals (which are more or less what savefig does anyways) if anyone is curious about what happens under the hood).

Copy link
Member

Choose a reason for hiding this comment

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

Then let's spell it like this

Suggested change
# Option 2: Manually attach a canvas to the figure (pyplot or savefig would
# Option 2: Low-level approach to directly save to a numpy array
# Manually attach a canvas to the figure (pyplot or savefig would

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, done

Most fixes are self-explanatory.  The change to the flask command-line
allows using the same instructions on all OSes.  The one to the
CanvasAgg example is there because it is no longer (since mpl3.1)
necessary to explicitly attach the canvas in the savefig() case.
@timhoffm timhoffm added this to the v3.11.0 milestone Dec 14, 2025
@timhoffm timhoffm merged commit 420750c into matplotlib:main Dec 14, 2025
36 of 38 checks passed
@anntzer anntzer deleted the close branch December 14, 2025 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation: examples files in galleries/examples Documentation: user guide files in galleries/users_explain or doc/users Documentation topic: pyplot API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants