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

Skip to content

Commit f420992

Browse files
committed
Merge branch 'v2.0.x'
2 parents 47f2233 + 00b74bd commit f420992

File tree

11 files changed

+87
-11
lines changed

11 files changed

+87
-11
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
New rcParams
22
------------
33

4-
The parameters `xtick.top`, `xtick.bottom`, `ytick.left`
5-
and `ytick.right` were added to control where the ticks
6-
are drawn.
4+
The parameters ``xtick.top``, ``xtick.bottom``, ``ytick.left``
5+
and ``ytick.right`` were added to control where the ticks
6+
are drawn.
7+
8+
``hist.bins`` to control the default number of bins to use in
9+
`~matplotlib.axes.Axes.hist`. This can be an `int`, a list of floats, or
10+
``'auto'`` if numpy >= 1.11 is installed.

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4442,7 +4442,7 @@ def stackplot(self, x, *args, **kwargs):
44424442
label_namer=None)
44434443
def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
44444444
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
4445-
minlength=0.1, transform=None, zorder=1, start_points=None):
4445+
minlength=0.1, transform=None, zorder=2, start_points=None):
44464446
if not self._hold:
44474447
self.cla()
44484448
stream_container = mstream.streamplot(self, x, y, u, v,

lib/matplotlib/axes/_base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,13 @@ def set_color_cycle(self, clist):
11361136
"""
11371137
cbook.warn_deprecated(
11381138
'1.5', name='set_color_cycle', alternative='set_prop_cycle')
1139-
self.set_prop_cycle('color', clist)
1139+
if clist is None:
1140+
# Calling set_color_cycle() or set_prop_cycle() with None
1141+
# effectively resets the cycle, but you can't do
1142+
# set_prop_cycle('color', None). So we are special-casing this.
1143+
self.set_prop_cycle(None)
1144+
else:
1145+
self.set_prop_cycle('color', clist)
11401146

11411147
def ishold(self):
11421148
"""return the HOLD status of the axes"""

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ patch.facecolor : b
2929
patch.edgecolor : k
3030
patch.antialiased : True # render patches in antialiased (no jaggies)
3131

32+
hist.bins : 10
33+
3234
### FONT
3335
#
3436
# font properties used by text.Text. See

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3273,7 +3273,7 @@ def step(x, y, *args, **kwargs):
32733273
@_autogen_docstring(Axes.streamplot)
32743274
def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
32753275
norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1,
3276-
transform=None, zorder=1, start_points=None, hold=None, data=None):
3276+
transform=None, zorder=2, start_points=None, hold=None, data=None):
32773277
ax = gca()
32783278
# allow callers to override the hold state by passing hold=True|False
32793279
washold = ax.ishold()

lib/matplotlib/rcsetup.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,23 @@ def validate_cycler(s):
770770
return cycler_inst
771771

772772

773+
def validate_hist_bins(s):
774+
if isinstance(s, six.text_type) and s == 'auto':
775+
return s
776+
try:
777+
return int(s)
778+
except (TypeError, ValueError):
779+
pass
780+
781+
try:
782+
return validate_floatlist(s)
783+
except ValueError:
784+
pass
785+
786+
raise ValueError("'hist.bins' must be 'auto', an int or " +
787+
"a sequence of floats")
788+
789+
773790
# a map from key -> value, converter
774791
defaultParams = {
775792
'backend': ['Agg', validate_backend], # agg is certainly
@@ -814,7 +831,7 @@ def validate_cycler(s):
814831
'patch.antialiased': [True, validate_bool], # antialiased (no jaggies)
815832

816833
## Histogram properties
817-
'hist.bins': [10, validate_any],
834+
'hist.bins': [10, validate_hist_bins],
818835

819836
## Boxplot properties
820837
'boxplot.notch': [False, validate_bool],

lib/matplotlib/streamplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
2323
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
24-
minlength=0.1, transform=None, zorder=1, start_points=None):
24+
minlength=0.1, transform=None, zorder=2, start_points=None):
2525
"""Draws streamlines of a vector flow.
2626
2727
*x*, *y* : 1d arrays

lib/matplotlib/tests/test_cycles.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
from matplotlib.testing.decorators import image_comparison, cleanup
24
import matplotlib.pyplot as plt
35
import numpy as np
@@ -147,6 +149,30 @@ def test_valid_input_forms():
147149
assert True
148150

149151

152+
@cleanup
153+
def test_cycle_reset():
154+
fig, ax = plt.subplots()
155+
156+
# Can't really test a reset because only a cycle object is stored
157+
# but we can test the first item of the cycle.
158+
prop = next(ax._get_lines.prop_cycler)
159+
ax.set_prop_cycle(linewidth=[10, 9, 4])
160+
assert prop != next(ax._get_lines.prop_cycler)
161+
ax.set_prop_cycle(None)
162+
got = next(ax._get_lines.prop_cycler)
163+
assert prop == got, "expected %s, got %s" % (prop, got)
164+
165+
fig, ax = plt.subplots()
166+
# Need to double-check the old set/get_color_cycle(), too
167+
with warnings.catch_warnings():
168+
prop = next(ax._get_lines.prop_cycler)
169+
ax.set_color_cycle(['c', 'm', 'y', 'k'])
170+
assert prop != next(ax._get_lines.prop_cycler)
171+
ax.set_color_cycle(None)
172+
got = next(ax._get_lines.prop_cycler)
173+
assert prop == got, "expected %s, got %s" % (prop, got)
174+
175+
150176
@cleanup
151177
def test_invalid_input_forms():
152178
fig, ax = plt.subplots()

lib/matplotlib/tests/test_pickle.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ def test_transform():
279279
assert_equal(obj.wrapper._child, obj.composite)
280280
# Check child -> parent links of TransformWrapper.
281281
assert_equal(list(obj.wrapper._parents.values()), [obj.composite2])
282+
# Check input and output dimensions are set as expected.
283+
assert_equal(obj.wrapper.input_dims, obj.composite.input_dims)
284+
assert_equal(obj.wrapper.output_dims, obj.composite.output_dims)
282285

283286

284287
if __name__ == '__main__':

lib/matplotlib/tests/test_rcparams.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
validate_nseq_int,
2828
validate_nseq_float,
2929
validate_cycler,
30-
validate_hatch)
30+
validate_hatch,
31+
validate_hist_bins)
3132

3233

3334
mpl.rc('text', usetex=False)
@@ -363,7 +364,17 @@ def test_validators():
363364
),
364365
'fail': (('fish', ValueError),
365366
),
366-
}
367+
},
368+
{'validator': validate_hist_bins,
369+
'success': (('auto', 'auto'),
370+
('10', 10),
371+
('1, 2, 3', [1, 2, 3]),
372+
([1, 2, 3], [1, 2, 3]),
373+
(np.arange(15), np.arange(15))
374+
),
375+
'fail': (('aardvark', ValueError),
376+
)
377+
}
367378
)
368379

369380
for validator_dict in validation_tests:

lib/matplotlib/transforms.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,17 +1552,24 @@ def __eq__(self, other):
15521552
def __str__(self):
15531553
return str(self._child)
15541554

1555+
# NOTE: Transform.__[gs]etstate__ should be sufficient when using only
1556+
# Python 3.4+.
15551557
def __getstate__(self):
1556-
# only store the child and parents
1558+
# only store the child information and parents
15571559
return {
15581560
'child': self._child,
1561+
'input_dims': self.input_dims,
1562+
'output_dims': self.output_dims,
15591563
# turn the weakkey dictionary into a normal dictionary
15601564
'parents': dict(six.iteritems(self._parents))
15611565
}
15621566

15631567
def __setstate__(self, state):
15641568
# re-initialise the TransformWrapper with the state's child
15651569
self._init(state['child'])
1570+
# The child may not be unpickled yet, so restore its information.
1571+
self.input_dims = state['input_dims']
1572+
self.output_dims = state['output_dims']
15661573
# turn the normal dictionary back into a WeakValueDictionary
15671574
self._parents = WeakValueDictionary(state['parents'])
15681575

0 commit comments

Comments
 (0)