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

Suggest unexisting filename when saving displayed figure #3608

Closed
strazdas opened this issue Oct 2, 2014 · 8 comments
Closed

Suggest unexisting filename when saving displayed figure #3608

strazdas opened this issue Oct 2, 2014 · 8 comments

Comments

@strazdas
Copy link

strazdas commented Oct 2, 2014

Wanted feature Automatically update the suggested filename to save a figure to if a file with the default filename already exists.

Situation now The default interface always suggests figure_1.png filename even when it exists. This means that, each time I want to save a figure, I have to check how many figures I have and update the filename to figure_<number_of_figures+1>.png.

It would be great if It was possible to specify the filename pattern in matplotlibrc file.

An image of the interface:

@tacaswell tacaswell added this to the v1.5.x milestone Oct 2, 2014
@ghost
Copy link

ghost commented Mar 14, 2015

@strazdas @tacaswell How do you recommend specifying the pattern?
Currently I have a fix (that I'd like to get a PR in for at some point) that adopts the standard pattern when a filename exists. For example, if the window title of your figure is "Figure 1", then repeated saves would yield:

"figure_1.png", "figure_1 (1).png", "figure_1 (2).png" and etc.

If you wanted to specify the pattern, the only way I could see is specifying a boolean control for whether to inject a space between the number and title name, and which character you'd like to use as the brackets.

@efiring
Copy link
Member

efiring commented Mar 14, 2015

If you turn this into a PR, please don't try to put a space in the file name. Use another underscore, or a dash, or a dot.

@ghost
Copy link

ghost commented Mar 14, 2015

@efiring Thanks for the response. With underscores, we'd have
"figure_1.png", "figure_1_1.png", "figure_1_2.png", "figure_1_3.png" and etc.

How would you like to have it with dash or dots? Before or after the file's extension?

For example "figure_1-2.png" or "figure_1.png-2"; "figure_1.2.png" or "figure_1.png.2".

@efiring
Copy link
Member

efiring commented Mar 15, 2015

"figure_1-2.png" would work fine. One doesn't want to interfere with the extension, since so many programs use it to decide what to do with a file.

@efiring
Copy link
Member

efiring commented Mar 15, 2015

Also, the dash is probably better than a dot; some programs stupidly treat everything after the first dot as the extension. I am not aware of anything that would cause problems with a dash.

@ghost
Copy link

ghost commented Mar 15, 2015

Agreed! I will adjust the fix accordingly and aim to make a PR soon.

@umairidris
Copy link

Sorry @stallone1993! I already had this feature completed. Please see #4221. I would appreciate your feedback.

@ghost
Copy link

ghost commented Mar 15, 2015

@umairidris - thanks for the heads up. My fix is pretty similar to yours (though I had it completed earlier on in the day - just wanted to make sure I was solving it in the preferred way). Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants