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

Skip to content

Commit c1a1079

Browse files
committed
Merge pull request #1950 from pelson/matplotlib_doc
Tidy up the matplotlib.__init__ documentation.
2 parents c7278d2 + 9f0e939 commit c1a1079

File tree

3 files changed

+65
-32
lines changed

3 files changed

+65
-32
lines changed
Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,37 @@
11
The top level :mod:`matplotlib` module
22
======================================
33

4-
.. automodule:: matplotlib
5-
:members: rc, rcdefaults, use
6-
:undoc-members:
7-
:show-inheritance:
4+
5+
.. py:currentmodule:: matplotlib
6+
7+
.. autofunction:: use
8+
9+
.. autofunction:: get_backend
10+
11+
.. py:data:: matplotlib.rcParams
12+
13+
An instance of :class:`RcParams` for handling default matplotlib values.
14+
15+
.. autofunction:: rc
16+
17+
.. autofunction::rcdefaults
18+
19+
.. autofunction::rc_file
20+
21+
.. autofunction::rc_context
22+
23+
.. autofunction:: matplotlib_fname
24+
25+
.. autofunction::rc_file_defaults
26+
27+
.. autofunction::interactive
28+
29+
.. autofunction::is_interactive
30+
31+
.. autoclass:: RcParams
32+
33+
.. autofunction:: rc_params
34+
35+
.. autofunction:: rc_params_from_file
36+
37+
.. autoclass:: rc_context

doc/sphinxext/gen_gallery.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ def gen_gallery(app, doctree):
151151
fh.close()
152152

153153
for key in app.builder.status_iterator(
154-
iter(thumbnails.keys()), "generating thumbnails... ",
155-
length=len(thumbnails)):
156-
image.thumbnail(key, thumbnails[key], 0.3)
154+
iter(thumbnails.keys()), "generating thumbnails... ",
155+
length=len(thumbnails)):
156+
if out_of_date(key, thumbnails[key]):
157+
image.thumbnail(key, thumbnails[key], 0.3)
157158

158159

159160
def setup(app):

lib/matplotlib/__init__.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ def _get_configdir():
545545
configdir = os.environ.get('MPLCONFIGDIR')
546546
if configdir is not None:
547547
if not os.path.exists(configdir):
548+
from matplotlib.cbook import mkdirs
548549
mkdirs(configdir)
549550
if not _is_writable_dir(configdir):
550551
return _create_tmp_config_dir()
@@ -626,9 +627,9 @@ def get_example_data(fname):
626627

627628
def get_py2exe_datafiles():
628629
datapath = get_data_path()
629-
head, tail = os.path.split(datapath)
630+
_, tail = os.path.split(datapath)
630631
d = {}
631-
for root, dirs, files in os.walk(datapath):
632+
for root, _, files in os.walk(datapath):
632633
# Need to explicitly remove cocoa_agg files or py2exe complains
633634
# NOTE I dont know why, but do as previous version
634635
if 'Matplotlib.nib' in files:
@@ -642,7 +643,7 @@ def get_py2exe_datafiles():
642643

643644
def matplotlib_fname():
644645
"""
645-
Return the path to the rc file
646+
Return the path to the rc file used by matplotlib.
646647
647648
Search order:
648649
@@ -651,9 +652,7 @@ def matplotlib_fname():
651652
* HOME/.matplotlib/matplotlibrc
652653
* MATPLOTLIBDATA/matplotlibrc
653654
654-
655655
"""
656-
657656
oldname = os.path.join(os.getcwd(), '.matplotlibrc')
658657
if os.path.exists(oldname):
659658
try:
@@ -815,13 +814,14 @@ def find_all(self, pattern):
815814

816815

817816
def rc_params(fail_on_error=False):
818-
'Return the default params updated from the values in the rc file'
819-
817+
"""Return a :class:`matplotlib.RcParams` instance from the
818+
default matplotlib rc file.
819+
"""
820820
fname = matplotlib_fname()
821821
if not os.path.exists(fname):
822822
# this should never happen, default in mpl-data should always be found
823823
message = 'could not find rc file; returning defaults'
824-
ret = RcParams([ (key, default) for key, (default, converter) in \
824+
ret = RcParams([(key, default) for key, (default, _) in \
825825
defaultParams.iteritems() ])
826826
warnings.warn(message)
827827
return ret
@@ -830,29 +830,31 @@ def rc_params(fail_on_error=False):
830830

831831

832832
def rc_params_from_file(fname, fail_on_error=False):
833-
"""Load and return params from fname."""
834-
833+
"""Return a :class:`matplotlib.RcParams` instance from the
834+
contents of the given filename.
835+
"""
835836
cnt = 0
836837
rc_temp = {}
837838
with open(fname) as fd:
838839
for line in fd:
839840
cnt += 1
840-
strippedline = line.split('#',1)[0].strip()
841+
strippedline = line.split('#', 1)[0].strip()
841842
if not strippedline: continue
842-
tup = strippedline.split(':',1)
843-
if len(tup) !=2:
844-
warnings.warn('Illegal line #%d\n\t%s\n\tin file "%s"'%\
843+
tup = strippedline.split(':', 1)
844+
if len(tup) != 2:
845+
warnings.warn('Illegal line #%d\n\t%s\n\tin file "%s"' % \
845846
(cnt, line, fname))
846847
continue
847848
key, val = tup
848849
key = key.strip()
849850
val = val.strip()
850851
if key in rc_temp:
851-
warnings.warn('Duplicate key in file "%s", line #%d'%(fname,cnt))
852+
warnings.warn('Duplicate key in file "%s", line #%d' % \
853+
(fname, cnt))
852854
rc_temp[key] = (val, line, cnt)
853855

854-
ret = RcParams([ (key, default) for key, (default, converter) in \
855-
defaultParams.iteritems() ])
856+
ret = RcParams([(key, default) for key, (default, _) in \
857+
defaultParams.iteritems()])
856858

857859
for key in ('verbose.level', 'verbose.fileo'):
858860
if key in rc_temp:
@@ -1028,20 +1030,20 @@ class rc_context(object):
10281030
10291031
This allows one to do::
10301032
1031-
>>> with mpl.rc_context(fname='screen.rc'):
1032-
... plt.plot(x, a)
1033-
... with mpl.rc_context(fname='print.rc'):
1034-
... plt.plot(x, b)
1035-
... plt.plot(x, c)
1033+
with mpl.rc_context(fname='screen.rc'):
1034+
plt.plot(x, a)
1035+
with mpl.rc_context(fname='print.rc'):
1036+
plt.plot(x, b)
1037+
plt.plot(x, c)
10361038
10371039
The 'a' vs 'x' and 'c' vs 'x' plots would have settings from
10381040
'screen.rc', while the 'b' vs 'x' plot would have settings from
10391041
'print.rc'.
10401042
10411043
A dictionary can also be passed to the context manager::
10421044
1043-
>>> with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
1044-
... plt.plot(x, a)
1045+
with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
1046+
plt.plot(x, a)
10451047
10461048
The 'rc' dictionary takes precedence over the settings loaded from
10471049
'fname'. Passing a dictionary only is also valid.
@@ -1128,7 +1130,7 @@ def use(arg, warn=True, force=False):
11281130
reload(sys.modules['matplotlib.backends'])
11291131

11301132
def get_backend():
1131-
"Returns the current backend."
1133+
"""Return the name of the current backend."""
11321134
return rcParams['backend']
11331135

11341136
def interactive(b):

0 commit comments

Comments
 (0)