Skip to content

Commit e58fa07

Browse files
committed
replace cairo.format with savefig.format in rcParams, apply to most backends
replace some stray tabs with spaces
1 parent 946f58b commit e58fa07

12 files changed

+40
-67
lines changed

doc/pyplots/matplotlibrc

+12-13
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ backend : Agg
5959
# circles. See
6060
# http://matplotlib.sourceforge.net/matplotlib.patches.html for more
6161
# information on patch properties
62-
#patch.linewidth : 1.0 # edge width in points
63-
#patch.facecolor : blue
64-
#patch.edgecolor : black
65-
#patch.antialiased : True # render patches in antialised (no jaggies)
62+
#patch.linewidth : 1.0 # edge width in points
63+
#patch.facecolor : blue
64+
#patch.edgecolor : black
65+
#patch.antialiased : True # render patches in antialised (no jaggies)
6666

6767
### FONT
6868
#
@@ -152,11 +152,11 @@ backend : Agg
152152
#text.markup : 'plain' # Affects how text, such as titles and labels, are
153153
# interpreted by default.
154154
# 'plain': As plain, unformatted text
155-
# 'tex': As TeX-like text. Text between $'s will be
156-
# formatted as a TeX math expression.
157-
# This setting has no effect when text.usetex is True.
158-
# In that case, all text will be sent to TeX for
159-
# processing.
155+
# 'tex': As TeX-like text. Text between $'s will be
156+
# formatted as a TeX math expression.
157+
# This setting has no effect when text.usetex is True.
158+
# In that case, all text will be sent to TeX for
159+
# processing.
160160

161161
# The following settings allow you to select the fonts in math mode.
162162
# They map from a TeX font name to a fontconfig font pattern.
@@ -170,8 +170,8 @@ backend : Agg
170170
#mathtext.fontset : cm # Should be 'cm' (Computer Modern), 'stix',
171171
# 'stixsans' or 'custom'
172172
#mathtext.fallback_to_cm : True # When True, use symbols from the Computer Modern
173-
# fonts when a symbol can not be found in one of
174-
# the custom math fonts.
173+
# fonts when a symbol can not be found in one of
174+
# the custom math fonts.
175175

176176
### AXES
177177
# default face and edge color, default tick sizes,
@@ -266,8 +266,7 @@ figure.figsize : 6, 4 # figure size in inches
266266
#savefig.dpi : 100 # figure dots per inch
267267
#savefig.facecolor : white # figure facecolor when saving
268268
#savefig.edgecolor : white # figure edgecolor when saving
269-
270-
#cairo.format : png # png, ps, pdf, svg
269+
#savefig.format : png # png, ps, pdf, svg
271270

272271
# tk backend params
273272
#tk.window_focus : False # Maintain shell focus for TkAgg

lib/matplotlib/__init__.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ def byte2str(b): return b
144144

145145
from matplotlib.rcsetup import (defaultParams,
146146
validate_backend,
147-
validate_toolbar,
148-
validate_cairo_format)
147+
validate_toolbar)
149148

150149
major, minor1, minor2, s, tmp = sys.version_info
151150
_python24 = (major == 2 and minor1 >= 4) or major >= 3
@@ -943,10 +942,7 @@ def use(arg, warn=True):
943942
be_parts = arg.split('.')
944943
name = validate_backend(be_parts[0])
945944
if len(be_parts) > 1:
946-
if name == 'cairo':
947-
rcParams['cairo.format'] = validate_cairo_format(be_parts[1])
948-
else:
949-
raise ValueError('Only cairo backend has a format option')
945+
raise ValueError('FIXME: Not sure what to do here')
950946
rcParams['backend'] = name
951947

952948
def get_backend():

lib/matplotlib/backend_bases.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
20782078

20792079

20802080
def get_default_filetype(self):
2081-
raise NotImplementedError
2081+
return rcParams['savefig.format']
20822082

20832083
def set_window_title(self, title):
20842084
"""

lib/matplotlib/backends/backend_agg.py

-3
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,6 @@ def buffer_rgba(self):
463463
'debug-annoying')
464464
return self.renderer.buffer_rgba()
465465

466-
def get_default_filetype(self):
467-
return 'png'
468-
469466
def print_raw(self, filename_or_obj, *args, **kwargs):
470467
FigureCanvasAgg.draw(self)
471468
renderer = self.get_renderer()

lib/matplotlib/backends/backend_cairo.py

-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
4646
from matplotlib.path import Path
4747
from matplotlib.transforms import Bbox, Affine2D
4848
from matplotlib.font_manager import ttfFontProperty
49-
from matplotlib import rcParams
5049

5150
_debug = False
5251
#_debug = True
@@ -430,9 +429,6 @@ def print_svg(self, fobj, *args, **kwargs):
430429
def print_svgz(self, fobj, *args, **kwargs):
431430
return self._save(fobj, 'svgz', *args, **kwargs)
432431

433-
def get_default_filetype(self):
434-
return rcParams['cairo.format']
435-
436432
def _save (self, fo, format, **kwargs):
437433
# save PDF/PS/SVG
438434
orientation = kwargs.get('orientation', 'portrait')

lib/matplotlib/backends/backend_gdk.py

-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def fn_name(): return sys._getframe(1).f_code.co_name
2828
from matplotlib.transforms import Affine2D
2929
from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
3030

31-
3231
backend_version = "%d.%d.%d" % gtk.pygtk_version
3332
_debug = False
3433

@@ -465,6 +464,3 @@ def _print_image(self, filename, format, *args, **kwargs):
465464
0, 0, 0, 0, width, height)
466465

467466
pixbuf.save(filename, format)
468-
469-
def get_default_filetype(self):
470-
return 'png'

lib/matplotlib/backends/backend_gtk.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name
4040
from matplotlib import markers
4141
from matplotlib import cbook
4242
from matplotlib import verbose
43+
from matplotlib import rcParams
4344

4445
backend_version = "%d.%d.%d" % gtk.pygtk_version
4546

@@ -474,9 +475,6 @@ def save_callback(buf, data=None):
474475
else:
475476
raise ValueError("filename must be a path or a file-like object")
476477

477-
def get_default_filetype(self):
478-
return 'png'
479-
480478
def new_timer(self, *args, **kwargs):
481479
"""
482480
Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
@@ -606,9 +604,9 @@ def full_screen_toggle (self):
606604
def _get_toolbar(self, canvas):
607605
# must be inited after the window, drawingArea and figure
608606
# attrs are set
609-
if matplotlib.rcParams['toolbar'] == 'classic':
607+
if rcParams['toolbar'] == 'classic':
610608
toolbar = NavigationToolbar (canvas, self.window)
611-
elif matplotlib.rcParams['toolbar'] == 'toolbar2':
609+
elif rcParams['toolbar'] == 'toolbar2':
612610
toolbar = NavigationToolbar2GTK (canvas, self.window)
613611
else:
614612
toolbar = None
@@ -698,7 +696,7 @@ def _init_toolbar(self):
698696

699697

700698
def _init_toolbar2_4(self):
701-
basedir = os.path.join(matplotlib.rcParams['datapath'],'images')
699+
basedir = os.path.join(rcParams['datapath'],'images')
702700
if not _new_tooltip_api:
703701
self.tooltips = gtk.Tooltips()
704702

@@ -1257,7 +1255,7 @@ def on_dialog_lineprops_cancelbutton_clicked(self, button):
12571255
icon_filename = 'matplotlib.png'
12581256
else:
12591257
icon_filename = 'matplotlib.svg'
1260-
window_icon = os.path.join(matplotlib.rcParams['datapath'], 'images', icon_filename)
1258+
window_icon = os.path.join(rcParams['datapath'], 'images', icon_filename)
12611259
except:
12621260
window_icon = None
12631261
verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1])

lib/matplotlib/backends/backend_gtk3.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name
2222
from matplotlib import lines
2323
from matplotlib import cbook
2424
from matplotlib import verbose
25+
from matplotlib import rcParams
2526

2627
backend_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_micro_version(), Gtk.get_minor_version())
2728

@@ -303,9 +304,6 @@ def idle_draw(*args):
303304
if self._idle_draw_id == 0:
304305
self._idle_draw_id = GObject.idle_add(idle_draw)
305306

306-
def get_default_filetype(self):
307-
return 'png'
308-
309307
def new_timer(self, *args, **kwargs):
310308
"""
311309
Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
@@ -435,9 +433,9 @@ def full_screen_toggle (self):
435433
def _get_toolbar(self, canvas):
436434
# must be inited after the window, drawingArea and figure
437435
# attrs are set
438-
if matplotlib.rcParams['toolbar'] == 'classic':
436+
if rcParams['toolbar'] == 'classic':
439437
toolbar = NavigationToolbar (canvas, self.window)
440-
elif matplotlib.rcParams['toolbar'] == 'toolbar2':
438+
elif rcParams['toolbar'] == 'toolbar2':
441439
toolbar = NavigationToolbar2GTK3 (canvas, self.window)
442440
else:
443441
toolbar = None
@@ -512,7 +510,7 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
512510

513511
def _init_toolbar(self):
514512
self.set_style(Gtk.ToolbarStyle.ICONS)
515-
basedir = os.path.join(matplotlib.rcParams['datapath'],'images')
513+
basedir = os.path.join(rcParams['datapath'],'images')
516514

517515
for text, tooltip_text, image_file, callback in self.toolitems:
518516
if text is None:
@@ -1055,7 +1053,7 @@ def on_dialog_lineprops_cancelbutton_clicked(self, button):
10551053
icon_filename = 'matplotlib.png'
10561054
else:
10571055
icon_filename = 'matplotlib.svg'
1058-
window_icon = os.path.join(matplotlib.rcParams['datapath'], 'images', icon_filename)
1056+
window_icon = os.path.join(rcParams['datapath'], 'images', icon_filename)
10591057
except:
10601058
window_icon = None
10611059
verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1])

lib/matplotlib/backends/backend_macosx.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from matplotlib.path import Path
1414
from matplotlib.mathtext import MathTextParser
1515
from matplotlib.colors import colorConverter
16-
16+
from matplotlib import rcParams
1717

1818
from matplotlib.widgets import SubplotTool
1919

@@ -225,7 +225,7 @@ def draw_if_interactive():
225225
it will be redrawn as soon as the event loop resumes via PyOS_InputHook.
226226
This function should be called after each draw event, even if
227227
matplotlib is not running interactively.
228-
"""
228+
"""
229229
if matplotlib.is_interactive():
230230
figManager = Gcf.get_active()
231231
if figManager is not None:
@@ -330,9 +330,6 @@ def print_tiff(self, filename, *args, **kwargs):
330330
def print_gif(self, filename, *args, **kwargs):
331331
self._print_bitmap(filename, *args, **kwargs)
332332

333-
def get_default_filetype(self):
334-
return 'png'
335-
336333
def new_timer(self, *args, **kwargs):
337334
"""
338335
Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
@@ -357,9 +354,9 @@ def __init__(self, canvas, num):
357354
FigureManagerBase.__init__(self, canvas, num)
358355
title = "Figure %d" % num
359356
_macosx.FigureManager.__init__(self, canvas, title)
360-
if matplotlib.rcParams['toolbar']=='classic':
357+
if rcParams['toolbar']=='classic':
361358
self.toolbar = NavigationToolbarMac(canvas)
362-
elif matplotlib.rcParams['toolbar']=='toolbar2':
359+
elif rcParams['toolbar']=='toolbar2':
363360
self.toolbar = NavigationToolbar2Mac(canvas)
364361
else:
365362
self.toolbar = None
@@ -384,7 +381,7 @@ class NavigationToolbarMac(_macosx.NavigationToolbar):
384381

385382
def __init__(self, canvas):
386383
self.canvas = canvas
387-
basedir = os.path.join(matplotlib.rcParams['datapath'], "images")
384+
basedir = os.path.join(rcParams['datapath'], "images")
388385
images = {}
389386
for imagename in ("stock_left",
390387
"stock_right",
@@ -453,7 +450,7 @@ def __init__(self, canvas):
453450
NavigationToolbar2.__init__(self, canvas)
454451

455452
def _init_toolbar(self):
456-
basedir = os.path.join(matplotlib.rcParams['datapath'], "images")
453+
basedir = os.path.join(rcParams['datapath'], "images")
457454
_macosx.NavigationToolbar2.__init__(self, basedir)
458455

459456
def draw_rubberband(self, event, x0, y0, x1, y1):

lib/matplotlib/backends/backend_wx.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1190,9 +1190,6 @@ def _print_image(self, filename, filetype, *args, **kwargs):
11901190
self.draw()
11911191
self.Refresh()
11921192

1193-
def get_default_filetype(self):
1194-
return 'png'
1195-
11961193
def _onPaint(self, evt):
11971194
"""
11981195
Called when wxPaintEvt is generated
@@ -1513,9 +1510,9 @@ def __init__(self, num, fig):
15131510
bind(self, wx.EVT_CLOSE, self._onClose)
15141511

15151512
def _get_toolbar(self, statbar):
1516-
if matplotlib.rcParams['toolbar']=='classic':
1513+
if rcParams['toolbar']=='classic':
15171514
toolbar = NavigationToolbarWx(self.canvas, True)
1518-
elif matplotlib.rcParams['toolbar']=='toolbar2':
1515+
elif rcParams['toolbar']=='toolbar2':
15191516
toolbar = NavigationToolbar2Wx(self.canvas)
15201517
toolbar.set_status_bar(statbar)
15211518
else:

lib/matplotlib/rcsetup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ def validate_font_properties(s):
251251
'silent', 'helpful', 'debug', 'debug-annoying',
252252
])
253253

254-
validate_cairo_format = ValidateInStrings('cairo_format',
255-
['png', 'ps', 'pdf', 'svg'],
256-
ignorecase=True)
254+
validate_savefig_format = ValidateInStrings('savefig_format',
255+
['png', 'ps', 'pdf', 'svg'],
256+
ignorecase=True)
257257

258258
validate_ps_papersize = ValidateInStrings('ps_papersize',[
259259
'auto', 'letter', 'legal', 'ledger',
@@ -547,8 +547,8 @@ def __call__(self, s):
547547
'savefig.edgecolor' : ['w', validate_color], # edgecolor; white
548548
'savefig.orientation' : ['portrait', validate_orientation], # edgecolor; white
549549
'savefig.extension' : ['auto', str], # what to add to extensionless filenames
550+
'savefig.format' : ['png', validate_savefig_format],
550551

551-
'cairo.format' : ['png', validate_cairo_format],
552552
'tk.window_focus' : [False, validate_bool], # Maintain shell focus for TkAgg
553553
'tk.pythoninspect' : [False, validate_tkpythoninspect], # obsolete
554554
'ps.papersize' : ['letter', validate_ps_papersize], # Set the papersize/type

matplotlibrc.template

+3-4
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,7 @@ text.hinting_factor : 8 # Specifies the amount of softness for hinting in the
348348
#savefig.facecolor : white # figure facecolor when saving
349349
#savefig.edgecolor : white # figure edgecolor when saving
350350
#savefig.extension : auto # what extension to use for savefig('foo'), or 'auto'
351-
352-
#cairo.format : png # png, ps, pdf, svg
351+
#savefig.format : png # png, ps, pdf, svg
353352

354353
# tk backend params
355354
#tk.window_focus : False # Maintain shell focus for TkAgg
@@ -434,8 +433,8 @@ text.hinting_factor : 8 # Specifies the amount of softness for hinting in the
434433
# -1 implies let utility auto-determine
435434
#animation.frame_format: 'png' # Controls frame format used by temp files
436435
#animation.ffmpeg_path: 'ffmpeg' # Path to ffmpeg binary. Without full path
437-
# $PATH is searched
436+
# $PATH is searched
438437
#animation.ffmpeg_args: '' # Additional arugments to pass to mencoder
439438
#animation.mencoder_path: 'ffmpeg' # Path to mencoder binary. Without full path
440-
# $PATH is searched
439+
# $PATH is searched
441440
#animation.mencoder_args: '' # Additional arugments to pass to mencoder

0 commit comments

Comments
 (0)