-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Consolidate agg-buffer examples. #11726
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
agg_oo_sgskip, webapp_demo_sgskip, and histogram_demo_canvasagg_sgskip were all demonstrating the same thing (how to create a Figure outside of pyplot, attach a canvas, and get the data out either saved to a file or as a string. Consolidate them into a single example, with the minimal amount of plotting. (PIL.Image.frombytes exists since Pillow 2.0 which is the first version to support Py3.) agg_buffer is very similar but uses another (worse?) technique to attach an agg buffer; make data extraction simpler but otherwise keep it separate for now. Other related examples include: - agg_buffer_to_array which directly does `np.asarray(canvas.renderer._renderer)`, which is on the one side bad as it uses a private API, but on the other hand the only way (AFAIK) to access the underlying buffer without copy; - print_stdout_sgskip, which does use pyplot to set up the agg buffer. Let's defer the discussion for these two examples to later.
1d02261
to
870f851
Compare
At least I know that |
I don't mind moving everything to agg_oo_buffer instead if that makes you more comfortable. |
Ok, thinking about it, those links are broken anyways, so one needs to locate the examples through search anyways. The new name and title are much better now, so this is probably the more sustainable solution.
possibly in smaller font (if there exists a spinx rule for that). |
The link to agg_oo_sgkip won't be broken if I move everything to it... |
It is already broken. Versions of that example:
meaning that if it's moved again now, the link will be as broken as if you didn't do anything to it, because I strongly doubt that new links to the devdocs ( |
Let's just leave this as it is then? I know that @tacaswell has thought about examples redirection but I'd rather have a general solution before starting to pepper docs with refs to no-longer-existing docs. |
Ok, someone decided to break that link prior to this. So assuming there was a reason for this and since it got approved, this PR just builds on top and is fine by itself. |
agg_oo_sgskip, webapp_demo_sgskip, and histogram_demo_canvasagg_sgskip
were all demonstrating the same thing (how to create a Figure outside of
pyplot, attach a canvas, and get the data out either saved to a file or
as a string. Consolidate them into a single example, with the minimal
amount of plotting. (PIL.Image.frombytes exists since Pillow 2.0 which
is the first version to support Py3.)
agg_buffer is very similar but uses another (worse?) technique to attach
an agg buffer; make data extraction simpler but otherwise keep it
separate for now.
Other related examples include:
np.asarray(canvas.renderer._renderer)
, which is on the one side badas it uses a private API, but on the other hand the only way (AFAIK)
to access the underlying buffer without copy[*];
Let's defer the discussion for these two examples to later.
[*] The poorly named buffer_rgba method actually does a copy (in PyBytes_FromStringAndSize). Note that the Py2 version used to return a Py2 buffer object, with no copy (https://github.com/matplotlib/matplotlib/blob/v2.2.2/src/_backend_agg_wrapper.cpp#L589). This (the buffer protocol) is also already implemented by the renderer object itself; it's just a matter of publically exposing it.
PR Summary
PR Checklist