Skip to content
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

Add Save Tool to NbAgg Figure [backport to 1.4.x] #3974

Merged
merged 7 commits into from Jan 12, 2015

Conversation

blink1073
Copy link
Member

Adds a toolbar save icon that opens a new window with the image that can be saved to a local file.

screenshot from 2015-01-07 15 53 35

Also adds ability to save the figure using the "S" key.

@blink1073
Copy link
Member Author

cc @pelson

@pelson
Copy link
Member

pelson commented Jan 7, 2015

CC @mdboom based on the comment in #3972.

@blink1073 - the hardest part of this is figuring out where to go to download content.

If this is really a route we want to take (I personally don't see much of a use for a save button inside the notebook UI), then perhaps downloadify may be of interest.

@blink1073
Copy link
Member Author

@pelson, my use case is when the figure is part of a larger notebook UI. We could have a "Save" button in the UI, but this is more elegant and in keeping with the rest of the backends' toolbars.

@blink1073
Copy link
Member Author

New method: use the HTML5 input tag, so that when the user clicks the button it brings up a file selector dialog. This could be used for the webagg backend as well.

@blink1073
Copy link
Member Author

We can then push the save event back to the Python side, and use canvas.print_figure.

@mdboom
Copy link
Member

mdboom commented Jan 7, 2015

Cool. At least speaking for myself, we're always looking for more web/HTML5 development expertise, so feel free to fix up anything else you find that could be done better.

@blink1073
Copy link
Member Author

@mdboom, I'm a beginner at JS, but thanks for the vote of confidence!

@tacaswell
Copy link
Member

How do we deal with converting the figure to a png when the figure gets killed? Presumably we could just use that method to serve up a png? [disclaimer, making this up as I go]

@blink1073
Copy link
Member Author

Shucks, the input tag can only select files on the user's file system. I'm still puzzling out how select a new file.

@tacaswell tacaswell added this to the v1.4.3 milestone Jan 7, 2015
@blink1073
Copy link
Member Author

Success!

@blink1073
Copy link
Member Author

When you click the download button, it opens a new window with the image in the desired type, and you can save it from there.

@blink1073
Copy link
Member Author

@tacaswell, I don't follow your question.

@blink1073
Copy link
Member Author

Hmm, the only two formats that work are PNG and JPG, and the JPG doesn't look that great (it only shows a white background and the plot line itself). Should we just output PNG and remove the selector?

@tacaswell
Copy link
Member

This needs a re-base.

@blink1073
Copy link
Member Author

Done.

@tacaswell
Copy link
Member

Is there some reason the drop-down didn't get ported over to the nbagg ui? It seems useful to be able save vector graphics from the notebook.

On the other hand, users have access to *.savefig('...pdf') so not sure how compelling that use-case is as compared to the web-agg use-case.

@tacaswell
Copy link
Member

and everything here works as advertised for me.

@tacaswell tacaswell changed the title Add Save Tool to NbAgg Figure Add Save Tool to NbAgg Figure [backport to 1.4.x] Jan 12, 2015
@blink1073
Copy link
Member Author

At first I tried using toDataURL, but for all but JPEG it ended up falling back on PNG. With JPEG, it rendered the transparent background as black, obscuring the spines.

pelson added a commit that referenced this pull request Jan 12, 2015
Add Save Tool to NbAgg Figure
@pelson pelson merged commit d04c73c into matplotlib:master Jan 12, 2015
@pelson
Copy link
Member

pelson commented Jan 12, 2015

@tacaswell - do you have some git foo which allows you to cherry-pick a branch onto v1.4.x?

@tacaswell
Copy link
Member

Git co v1.4.x
Git cherry-pick hash_of_merge -m 1

Take a look that it added just one commit past upstream v1.4.x with all of
the changes squashed and then push to upstream.

That should probably be documented some place

On Mon, Jan 12, 2015, 08:13 Phil Elson notifications@github.com wrote:

@tacaswell https://github.com/tacaswell - do you have some git foo
which allows you to cherry-pick a branch onto v1.4.x?


Reply to this email directly or view it on GitHub
#3974 (comment)
.

pelson added a commit that referenced this pull request Jan 13, 2015
@tacaswell
Copy link
Member

back-ported as 408fed6

@pelson
Copy link
Member

pelson commented Jan 13, 2015

Seems to have been merged into v1.4.x with 408fed6. (doh - too early in the morning - I should have refreshed my browser)

@tacaswell
Copy link
Member

Yes

On Tue, Jan 13, 2015, 05:08 Phil Elson notifications@github.com wrote:

Seems to have been merged into v1.4.x with 408fed6
408fed6.
Wasn't me though... @tacaswell https://github.com/tacaswell - did you
do it?


Reply to this email directly or view it on GitHub
#3974 (comment)
.

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.

None yet

4 participants