renamercParams['savefig.directory']
to rcParams['gui.save.directory']
#20790
Comments
This behavior is intentional and will almost certainly not change. Perhaps it could be better documented, though? |
I dunno, docs are pretty explicit:
I'd vote to close this.... |
OK, If it's a wontfix I think it will be worth mentioning in the documentation for |
I am not sure how the rcParam could be any more explicit, though I agree it was poorly named. I guess we could deprecate the rcParam and rename it guisavefig.... |
Well, I have to confess that I didn't come here after reading the rc('savefig', dpi=600, transparent=True, directory='/path/to/folder')
...
fig.savefig('file.png') Which works for the dpi and transparency. Personally it would be useful to me to be able to set the save directory programmatically. For example, when running a pipeline that produces many figures, its convenient to set the output directory at startup and then subsequently only having to use filenames instead of the full path when saving figures.
Just curious why you see this is as the case? I'm not proposing to change the default behaviour where
What will this require? Inside
then parse it and only if it's not absolute, prepend the rc directory. I think this will make the API more consistent. Are there people that set |
Additionally, |
I very much agree with @QuLogic that I think the path forward here is to rename This came in via #1685 if people want to see the original discussion. |
+1 for renaming. How about I think I don‘t see a strong case for switching to bool. Giving directory explicitly allows for a special default place to sore images to. I don‘t think we should strip that feature (and I personally use that sometimes). If anything sticky_last_path should be an additional option. But as long as nobody asks for it, I wouldn’t go there. |
I agree we should not drop the feature. The strongest argument for switching to bool is that I think this on one of two rcparam that we expect to be changed by the library code under normal operations (the other is 'backend' which we only change once from the secret sentinel to the selected backend so the user can never (without cheating) observe it change) so it is just a bit funny / defies the expectation that "rcparams is a place for users to pass global default parameters to Matplotlib" (by being "a place for Matplotlib to stash some internal state"). |
I'd say that "rcparams is the space to store (global) config state". It's not internal (and also |
The distinction I was trying to draw is between the user change the state vs us changing the state. I'm not going to push this farther and am happy with |
Figure.savefig
does not respect rcParams['savefig.directory']
rcParams['savefig.directory']
to `rcParams['gui.save.directory']
rcParams['savefig.directory']
to `rcParams['gui.save.directory']rcParams['savefig.directory']
to rcParams['gui.save.directory']
Thanks for the insights @QuLogic and @tacaswell. I'll try submit a PR when I have the bandwidth available. |
Bug summary
Figures saved via the
savefig
method are not saved relative to thercParams['savefig.directory']
path. Looking at the source code, it seems that this path is only prepended to the filename if the save request came via the interactive toolbar. Not sure if this is done intentionally, but it seems to me that thesavefig.directory
should always be respected.In the example below I use the home directory
~
, but the same behaviour occurs for any other existing directory.Code for reproduction
Actual outcome
The figure is saved in the local working directory.
Expected outcome
If
rcParams['savefig.directory']
has been set, andsavefig
is given a filename (not a full path), the figure should be saved relative tosavefig.directory
.Operating system
Ubuntu
Matplotlib Version
3.3.4
Matplotlib Backend
Qt5Agg
Python version
3.8.10
Jupyter version
NA
Other libraries
No response
Installation
pip
Conda channel
No response
The text was updated successfully, but these errors were encountered: