8000 Merge remote-tracking branch 'matplotlib/v2.x' · matplotlib/matplotlib@73f90a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 73f90a2

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
2 parents cf38ed7 + 8ec4455 commit 73f90a2

File tree

19 files changed

+116
-47
lines changed

19 files changed

+116
-47
lines changed

doc/_templates/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ <h1>John Hunter (1968-2012)</h1>
9393
If you have benefited from John's many contributions, please say
9494
thanks in the way that would matter most to him. Please consider
9595
making a donation to
96-
the <a href="http://numfocus.org/johnhunter/">John Hunter Memorial
97-
Fund</a>.</p>
96+
the <a href="http://numfocus.org/johnhunter/">John Hunter Technology
97+
Fellowship</a>.</p>
9898
</td>
9999
</tr>
100100
</table>

doc/pyplots/whats_new_98_4_fancy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def make_boxstyles(ax):
99
styles = mpatch.BoxStyle.get_styles()
1010

11-
for i, (stylename, styleclass) in enumerate(styles.items()):
11+
for i, (stylename, styleclass) in enumerate(sorted(styles.items())):
1212
ax.text(0.5, (float(len(styles)) - 0.5 - i)/len(styles), stylename,
1313
ha="center",
1414
size=fontsize,

doc/users/whats_new/rcparams.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1-
Added ``svg.hashsalt`` key to rcParams
2-
```````````````````````````````````````
1+
Configuration (rcParams)
2+
------------------------
3+
4+
+----------------------------+--------------------------------------------------+
5+
| Parameter | Description |
6+
+============================+==================================================+
7+
|`date.autoformatter.year` | foramt string for 'year' scale dates |
8+
+----------------------------+--------------------------------------------------+
9+
|`date.autoformatter.month` | format string for 'month' scale dates |
10+
+----------------------------+--------------------------------------------------+
11+
|`date.autoformatter.day` | format string for 'day' scale dates |
12+
+----------------------------+--------------------------------------------------+
13+
|`date.autoformatter.hour` | format string for 'hour' scale times |
14+
+----------------------------+--------------------------------------------------+
15+
|`date.autoformatter.minute` | format string for 'minute' scale times |
16+
+----------------------------+--------------------------------------------------+
17+
|`date.autoformatter.second` | format string for 'second' scale times |
18+
+----------------------------+--------------------------------------------------+
19+
|`svg.hashsalt` | see note |
20+
+----------------------------+--------------------------------------------------+
21+
22+
``svg.hashsalt``
23+
````````````````
24+
325
If ``svg.hashsalt`` is ``None`` (which it is by default), the svg backend uses ``uuid4`` to generate the hash salt.
426
If it is not ``None``, it must be a string that is used as the hash salt instead of ``uuid4``.
527
This allows for deterministic SVG output.

examples/api/filled_step.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import itertools
2+
from collections import OrderedDict
23
from functools import partial
34

45
import numpy as np
@@ -174,9 +175,9 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
174175
hatch_cycle = cycler('hatch', ['/', '*', '+', '|'])
175176

176177
# make some synthetic data
178+
np.random.seed(0)
177179
stack_data = np.random.randn(4, 12250)
178-
dict_data = {lab: d for lab, d in zip(list(c['label'] for c in label_cycle),
179-
stack_data)}
180+
dict_data = OrderedDict(zip((c['label'] for c in label_cycle), stack_data))
180181

181182
# work with plain arrays
182183
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 4.5), tight_layout=True)

examples/color/named_colors.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@
3333
sat = [color[1] for color in hsv]
3434
val = [color[2] for color in hsv]
3535

36-
# Sort by hue, saturation and value.
37-
ind = np.lexsort((val, sat, hue))
36+
# Get the color names by themselves.
37+
names = [color[0] for color in colors_]
38+
39+
# Sort by hue, saturation, value and name.
40+
ind = np.lexsort((names, val, sat, hue))
3841
sorted_colors = [colors_[i] for i in ind]
3942

4043
n = len(sorted_colors)

examples/pylab_examples/arrow_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
214214
plt.text(x, y, label, size=label_text_size, ha='center', va='center',
215215
color=labelcolor or fc)
216216

217-
for p in positions.keys():
217+
for p in sorted(positions):
218218
draw_arrow(p)
219219

220220
# test data

examples/pylab_examples/boxplot_demo2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
randomDists = ['Normal(1,1)', ' Lognormal(1,1)', 'Exp(1)', 'Gumbel(6,4)',
1717
'Triangular(2,9,11)']
1818
N = 500
19+
np.random.seed(0)
1920
norm = np.random.normal(1, 1, N)
2021
logn = np.random.lognormal(1, 1, N)
2122
expo = np.random.exponential(1, N)

examples/pylab_examples/demo_tight_layout.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11

22
import matplotlib.pyplot as plt
3+
import itertools
34
import warnings
45

5-
import random
6-
fontsizes = [8, 16, 24, 32]
6+
7+
fontsizes = itertools.cycle([8, 16, 24, 32])
78

89

910
def example_plot(ax):
1011
ax.plot([1, 2])
11-
ax.set_xlabel('x-label', fontsize=random.choice(fontsizes))
12-
ax.set_ylabel('y-label', fontsize=random.choice(fontsizes))
13-
ax.set_title('Title', fontsize=random.choice(fontsizes))
12+
ax.set_xlabel('x-label', fontsize=next(fontsizes))
13+
ax.set_ylabel('y-label', fontsize=next(fontsizes))
14+
ax.set_title('Title', fontsize=next(fontsizes))
15+
1416

1517
fig, ax = plt.subplots()
1618
example_plot(ax)

examples/pylab_examples/spectrum_demo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import matplotlib.pyplot as plt
22
import numpy as np
33

4+
5+
np.random.seed(0)
6+
47
dt = 0.01
58
Fs = 1/dt
69
t = np.arange(0, 10, dt)

examples/pylab_examples/system_monitor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import matplotlib.pyplot as plt
22
import numpy as np
33

4+
5+
np.random.seed(0)
6+
47
x, y = np.random.randn(2, 100)
58
fig = plt.figure()
69
ax1 = fig.add_subplot(211)

lib/matplotlib/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ def param(func):
17121712
arg_names = []
17131713
elif len(_arg_names) > 1 and (positional_parameter_names is None):
17141714
# we got no manual parameter names but more than an 'ax' ...
1715-
if len(set(replace_names) - set(_arg_names[1:])) == 0:
1715+
if len(replace_names - set(_arg_names[1:])) == 0:
17161716
# all to be replaced arguments are in the list
17171717
arg_names = _arg_names[1:]
17181718
else:
@@ -1860,7 +1860,7 @@ def inner(ax, *args, **kwargs):
18601860
_repl = "* All arguments with the following names: '{names}'."
18611861
if replace_all_args:
18621862
_repl += "\n* All positional arguments."
1863-
_repl = _repl.format(names="', '".join(replace_names))
1863+
_repl = _repl.format(names="', '".join(sorted(replace_names)))
18641864
inner.__doc__ = (pre_doc +
18651865
_DATA_DOC_APPENDIX.format(replaced=_repl))
18661866
if not python_has_wrapped:

lib/matplotlib/artist.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,7 @@ def aliased_name(self, s):
12681268

12691269
if s in self.aliasd:
12701270
return s + ''.join([' or %s' % x
1271-
for x
1272-
in six.iterkeys(self.aliasd[s])])
1271+
for x in sorted(self.aliasd[s])])
12731272
else:
12741273
return s
12751274

@@ -1285,8 +1284,7 @@ def aliased_name_rest(self, s, target):
12851284

12861285
if s in self.aliasd:
12871286
aliases = ''.join([' or %s' % x
1288-
for x
1289-
in six.iterkeys(self.aliasd[s])])
1287+
for x in sorted(self.aliasd[s])])
12901288
else:
12911289
aliases = ''
12921290
return ':meth:`%s <%s>`%s' % (s, target, aliases)

lib/matplotlib/dates.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@
113113
unicode_literals)
114114

115115
from matplotlib.externals import six
116-
from matplotlib.externals.six.moves import xrange, zip
117-
116+
from matplotlib.externals.six.moves import zip
117+
from matplotlib import rcParams
118118
import re
119119
import time
120120
import math
@@ -629,12 +629,12 @@ class AutoDateFormatter(ticker.Formatter):
629629
format string. The default looks like this::
630630
631631
self.scaled = {
632-
365.0 : '%Y',
633-
30. : '%b %Y',
634-
1.0 : '%b %d %Y',
635-
1./24. : '%H:%M:%S',
636-
1. / (24. * 60.): '%H:%M:%S.%f',
637-
}
632+
DAYS_PER_YEAR: rcParams['date.autoformat.year'],
633+
DAYS_PER_MONTH: rcParams['date.autoformat.month'],
634+
1.0: rcParams['date.autoformat.day'],
635+
1. / HOURS_PER_DAY: rcParams['date.autoformat.hour'],
636+
1. / (MINUTES_PER_DAY): rcParams['date.autoformat.minute'],
637+
1. / (SEC_PER_DAY): rcParams['date.autoformat.second']}
638638
639639
640640
The algorithm picks the key in the dictionary that is >= the
@@ -685,11 +685,14 @@ def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
685685
self._tz = tz
686686
self.defaultfmt = defaultfmt
687687
self._formatter = DateFormatter(self.defaultfmt, tz)
688-
self.scaled = {DAYS_PER_YEAR: '%Y',
689-
DAYS_PER_MONTH: '%b %Y',
690-
1.0: '%b %d %Y',
691-
1. / HOURS_PER_DAY: '%H:%M:%S',
692-
1. / (MINUTES_PER_DAY): '%H:%M:%S.%f'}
688+
self.scaled = {DAYS_PER_YEAR: rcParams['date.autoformatter.year'],
689+
DAYS_PER_MONTH: rcParams['date.autoformatter.month'],
690+
1.0: rcParams['date.autoformatter.day'],
691+
1. / HOURS_PER_DAY: rcParams['date.autoformatter.hour'],
692+
1. / (MINUTES_PER_DAY):
693+
rcParams['date.autoformatter.minute'],
694+
1. / (SEC_PER_DAY):
695+
rcParams['date.autoformatter.second']}
693696

694697
def __call__(self, x, pos=None):
695698
locator_unit_scale = float(self._locator._get_unit())

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ axes.spines.top : True
215215
polaraxes.grid : True # display grid on polar axes
216216
axes3d.grid : True # display grid on 3d axes
217217

218+
date.autoformatter.year : %Y
219+
date.autoformatter.month : %b %Y
220+
date.autoformatter.day : %b %d %Y
221+
date.autoformatter.hour : %H:%M:%S
222+
date.autoformatter.minute : %H:%M:%S.%f
223+
date.autoformatter.second : %H:%M:%S.%f
224+
218225
### TICKS
219226
# see http://matplotlib.org/api/axis_api.html#matplotlib.axis.Tick
220227

lib/matplotlib/rcsetup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,13 @@ def validate_hist_bins(s):
10151015
'polaraxes.grid': [True, validate_bool], # display polar grid or
10161016
# not
10171017
'axes3d.grid': [True, validate_bool], # display 3d grid
1018+
# TODO validate that these are valid datetime format strings
1019+
'date.autoformatter.year': ['%Y', six.text_type],
1020+
'date.autoformatter.month': ['%Y-%m', six.text_type],
1021+
'date.autoformatter.day': ['%Y-%m-%d', six.text_type],
1022+
'date.autoformatter.hour': ['%H:%M', six.text_type],
1023+
'date.autoformatter.minute': ['%H:%M:%S', six.text_type],
1024+
'date.autoformatter.second': ['%H:%M:%S.%f', six.text_type],
10181025

10191026
#legend properties
10201027
'legend.fancybox': [False, validate_bool],

matplotlibrc.template

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# You can also deploy your own backend outside of matplotlib by
3636
# referring to the module name (which must be in the PYTHONPATH) as
3737
# 'module://my_backend'.
38-
backend : %(backend)s
38+
backend : $TEMPLATE_BACKEND
3939

4040
# If you are using the Qt4Agg backend, you can choose here
4141
# to use the PyQt4 bindings or the newer PySide bindings to
@@ -311,6 +311,7 @@ backend : %(backend)s
311311
# small compared to the minimum absolute
312312
# value of the data.
313313

314+
314315
#axes.unicode_minus : True # use unicode for the minus symbol
315316
# rather than hyphen. See
316317
# http://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes
@@ -328,6 +329,22 @@ backend : %(backend)s
328329
#polaraxes.grid : True # display grid on polar axes
329330
#axes3d.grid : True # display grid on 3d axes
330331

332+
### DATES
333+
# These control the default format strings used in AutoDateFormatter.
334+
# Any valid format datetime format string can be used (see the python
335+
# `datetime` for details). For example using '%%x' will use the locale date representation
336+
# '%%X' will use the locale time representation and '%%c' will use the full locale datetime
337+
# representation.
338+
# These values map to the scales:
339+
# {'year': 365, 'month': 30, 'day': 1, 'hour': 1/24, 'minute': 1 / (24 * 60)}
340+
341+
# date.autoformatter.year : %Y
342+
# date.autoformatter.month : %Y-%m
343+
# date.autoformatter.day : %Y-%m-%d
344+
# date.autoformatter.hour : %H:%M
345+
# date.autoformatter.minute : %H:%M:%S
346+
# date.autoformatter.second : %H:%M:%S.%f
347+
331348
### TICKS
332349
# see http://matplotlib.org/api/axis_api.html#matplotlib.axis.Tick
333350

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
from __future__ import print_function, absolute_import
7-
7+
from string import Template
88
# This needs to be the very first thing to use distribute
99
from distribute_setup import use_setuptools
1010
use_setuptools()
@@ -244,8 +244,9 @@ def run(self):
244244
default_backend = setupext.options['backend']
245245
with open('matplotlibrc.template') as fd:
246246
template = fd.read()
247+
template = Template(template)
247248
with open('lib/matplotlib/mpl-data/matplotlibrc', 'w') as fd:
248-
fd.write(template % {'backend': default_backend})
249+
fd.write(template.safe_substitute(TEMPLATE_BACKEND=default_backend))
249250

250251
# Build in verbose mode if requested
251252
if setupext.options['verbose']:

tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ def run(extra_args):
5151
from matplotlib.testing import disable_internet
5252
disable_internet.turn_off_internet()
5353
extra_args.extend(['--eval-attr="not network"'])
54+
sys.argv.remove('--no-network')
5455

5556
run(extra_args)

0 commit comments

Comments
 (0)
0