Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check validity of savefig.format rcParam at runtime
remove support for 'cairo.pdf' type of backend specification
  • Loading branch information
mspacek committed Jun 3, 2012
commit 42002e27423716ebf9f0971928f89c1d6f56fadb
5 changes: 1 addition & 4 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,10 +939,7 @@ def use(arg, warn=True):
else:
# Lowercase only non-module backend names (modules are case-sensitive)
arg = arg.lower()
be_parts = arg.split('.')
name = validate_backend(be_parts[0])
if len(be_parts) > 1:
raise ValueError('FIXME: Not sure what to do here')
name = validate_backend(arg)
rcParams['backend'] = name

def get_backend():
Expand Down
12 changes: 11 additions & 1 deletion lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,7 @@ def print_tif(self, filename_or_obj, *args, **kwargs):
print_tiff = print_tif

def get_supported_filetypes(self):
"""Return dict of savefig file formats supported by this backend"""
return self.filetypes

def get_supported_filetypes_grouped(self):
Expand Down Expand Up @@ -2078,7 +2079,16 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',


def get_default_filetype(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my earlier comment, this method could really do with a docstring (whilst your there, get_supported_filetypes() and get_supported_filetypes_grouped() should get a docstring too, if possible).

return rcParams['savefig.format']
"""
Get the default savefig file format as specified in rcParams.
If invalid, use .png. Overridden in backends that only support
a single file type.
"""
default = rcParams['savefig.format']
if default in self.get_supported_filetypes():
return default
else:
return 'png'

def set_window_title(self, title):
"""
Expand Down