Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

explicitly missing key or empty str signals to use cwd

  • Loading branch information...
commit c18bbaded9f4eca0213d8859d0ae765aa4c25b7d 1 parent 4c8b930
@mspacek mspacek authored
View
9 lib/matplotlib/backends/backend_qt4.py
@@ -644,7 +644,7 @@ def save_figure(self, *args):
sorted_filetypes.sort()
default_filetype = self.canvas.get_default_filetype()
- startpath = matplotlib.rcParams.get('savefig.directory', os.getcwd())
+ startpath = matplotlib.rcParams.get('savefig.directory', '')
startpath = os.path.expanduser(startpath)
start = os.path.join(startpath, self.canvas.get_default_filename())
filters = []
@@ -659,7 +659,12 @@ def save_figure(self, *args):
fname = _getSaveFileName(self, "Choose a filename to save to",
start, filters, selectedFilter)
if fname:
- matplotlib.rcParams['savefig.directory'] = os.path.split(str(fname))[0]
+ if startpath == '':
+ # explicitly missing key or empty str signals to use cwd
+ matplotlib.rcParams['savefig.directory'] = startpath
+ else:
+ # save dir for next time
+ matplotlib.rcParams['savefig.directory'] = os.path.dirname(str(fname))
try:
self.canvas.print_figure( unicode(fname) )
except Exception as e:
View
3  lib/matplotlib/rcsetup.py
@@ -686,7 +686,8 @@ def __call__(self, s):
# options are 'tight', or 'standard'. 'standard' validates to None.
'savefig.bbox': [None, validate_bbox],
'savefig.pad_inches': [0.1, validate_float],
- 'savefig.directory': ['', str],
+ # default directory in savefig dialog box
+ 'savefig.directory': ['~', str],
# Maintain shell focus for TkAgg
'tk.window_focus': [False, validate_bool],
View
3  matplotlibrc.template
@@ -366,7 +366,8 @@ text.hinting_factor : 8 # Specifies the amount of softness for hinting in the
#savefig.format : png # png, ps, pdf, svg
#savefig.bbox : standard # 'tight' or 'standard'.
#savefig.pad_inches : 0.1 # Padding to be used when bbox is set to 'tight'
-#savefig.directory : ~ # default directory in savefig dialog box
+#savefig.directory : ~ # default directory in savefig dialog box,
+ # leave empty to always use current working directory
# tk backend params
#tk.window_focus : False # Maintain shell focus for TkAgg
Please sign in to comment.
Something went wrong with that request. Please try again.