Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitea1b2d7

Browse files
committed
Add a savefig.extension rcparam in preparation for pdf tests
svn path=/trunk/matplotlib/; revision=7829
1 parent59df055 commitea1b2d7

File tree

5 files changed

+43
-25
lines changed

5 files changed

+43
-25
lines changed

‎CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2009-09-27 Add a savefig.extension rcparam to control the default
2+
filename extension used by savefig. - JKS
3+
14
===============================================
25
2009-09-21 Tagged for release 0.99.1
36

‎doc/api/api_changes.rst

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ This chapter is a log of changes to matplotlib that affect the
77
outward-facing API. If updating matplotlib breaks your scripts, this
88
list may help describe what changes may be necessary in your code.
99

10+
Changes beyond 0.99.x
11+
=====================
12+
1013
* You can now print several figures to one pdf file. See the docstrings
1114
of the class:class:`matplotlib.backends.backend_pdf.PdfPages` for
1215
more information.
@@ -18,42 +21,43 @@ list may help describe what changes may be necessary in your code.
1821
.. _configobj:http://www.voidspace.org.uk/python/configobj.html
1922
.. _`enthought.traits`:http://code.enthought.com/projects/traits
2023

21-
Changes beyond 0.99.x
22-
=====================
24+
* The new rc parameter ``savefig.extension`` sets the filename extension
25+
that is used by:meth:`matplotlib.figure.Figure.savefig` if its *fname*
26+
argument lacks an extension.
2327

24-
In an effort to simplify the backend API, all clipping rectangles
25-
and paths are now passed in using GraphicsContext objects, even
26-
on collections and images. Therefore::
28+
*In an effort to simplify the backend API, all clipping rectangles
29+
and paths are now passed in using GraphicsContext objects, even
30+
on collections and images. Therefore::
2731

28-
draw_path_collection(self, master_transform, cliprect, clippath,
29-
clippath_trans, paths, all_transforms, offsets,
30-
offsetTrans, facecolors, edgecolors, linewidths,
31-
linestyles, antialiaseds, urls)
32+
draw_path_collection(self, master_transform, cliprect, clippath,
33+
clippath_trans, paths, all_transforms, offsets,
34+
offsetTrans, facecolors, edgecolors, linewidths,
35+
linestyles, antialiaseds, urls)
3236

33-
# is now
37+
# is now
3438

35-
draw_path_collection(self, gc, master_transform, paths, all_transforms,
36-
offsets, offsetTrans, facecolors, edgecolors,
37-
linewidths, linestyles, antialiaseds, urls)
39+
draw_path_collection(self, gc, master_transform, paths, all_transforms,
40+
offsets, offsetTrans, facecolors, edgecolors,
41+
linewidths, linestyles, antialiaseds, urls)
3842

3943

40-
draw_quad_mesh(self, master_transform, cliprect, clippath,
41-
clippath_trans, meshWidth, meshHeight, coordinates,
42-
offsets, offsetTrans, facecolors, antialiased,
43-
showedges)
44+
draw_quad_mesh(self, master_transform, cliprect, clippath,
45+
clippath_trans, meshWidth, meshHeight, coordinates,
46+
offsets, offsetTrans, facecolors, antialiased,
47+
showedges)
4448

45-
# is now
49+
# is now
4650

47-
draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
48-
coordinates, offsets, offsetTrans, facecolors,
49-
antialiased, showedges)
51+
draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
52+
coordinates, offsets, offsetTrans, facecolors,
53+
antialiased, showedges)
5054

5155

52-
draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None)
56+
draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None)
5357

54-
# is now
58+
# is now
5559

56-
draw_image(self, gc, x, y, im)
60+
draw_image(self, gc, x, y, im)
5761

5862
Changes in 0.99
5963
======================

‎lib/matplotlib/figure.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,11 @@ def savefig(self, *args, **kwargs):
986986
:class:`~matplotlib.backends.backend_pdf.PdfPages`.
987987
988988
If *format* is *None* and *fname* is a string, the output
989-
format is deduced from the extension of the filename.
989+
format is deduced from the extension of the filename. If
990+
the filename has no extension, the value of the rc parameter
991+
``savefig.extension`` is used. If that value is 'auto',
992+
the backend determines the extension.
993+
990994
If *fname* is not a string, remember to specify *format* to
991995
ensure that the correct backend is used.
992996
@@ -1033,6 +1037,11 @@ def savefig(self, *args, **kwargs):
10331037
ifkeynotinkwargs:
10341038
kwargs[key]=rcParams['savefig.%s'%key]
10351039

1040+
extension=rcParams['savefig.extension']
1041+
ifargsand'.'notinargs[0]andextension!='auto':
1042+
fname=args[0]+'.'+extension
1043+
args= (fname,)+args[1:]
1044+
10361045
transparent=kwargs.pop('transparent',False)
10371046
iftransparent:
10381047
original_figure_alpha=self.patch.get_alpha()

‎lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ def __call__(self, s):
511511
'savefig.facecolor' : ['w',validate_color],# facecolor; white
512512
'savefig.edgecolor' : ['w',validate_color],# edgecolor; white
513513
'savefig.orientation' : ['portrait',validate_orientation],# edgecolor; white
514+
'savefig.extension' : ['auto',str],# what to add to extensionless filenames
514515

515516
'cairo.format' : ['png',validate_cairo_format],
516517
'tk.window_focus' : [False,validate_bool],# Maintain shell focus for TkAgg

‎matplotlibrc.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ backend : %(backend)s
306306
#savefig.dpi : 100 # figure dots per inch
307307
#savefig.facecolor : white # figure facecolor when saving
308308
#savefig.edgecolor : white # figure edgecolor when saving
309+
#savefig.extension : auto # what extension to use for savefig('foo'), or 'auto'
309310

310311
#cairo.format : png # png, ps, pdf, svg
311312

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp