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

Skip to content

Commit 273da36

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
Conflicts: lib/matplotlib/backends/qt_editor/figureoptions.py - pep8 conflicts
2 parents 0dff252 + 5976e68 commit 273da36

File tree

6 files changed

+102
-25
lines changed

6 files changed

+102
-25
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,6 +3854,10 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
38543854
edgecolors = co
38553855
if facecolors is None:
38563856
facecolors = co
3857+
if c is not None:
3858+
raise ValueError("Supply a 'c' kwarg or a 'color' kwarg"
3859+
" but not both; they differ but"
3860+
" their functionalities overlap.")
38573861
if c is None:
38583862
if facecolors is not None:
38593863
c = facecolors
@@ -3862,6 +3866,9 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
38623866
c = 'b' # The original default
38633867
else:
38643868
c = self._get_patches_for_fill.get_next_color()
3869+
c_none = True
3870+
else:
3871+
c_none = False
38653872

38663873
if edgecolors is None and not rcParams['_internal.classic_mode']:
38673874
edgecolors = 'face'
@@ -3889,16 +3896,19 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
38893896
# c is an array for mapping. The potential ambiguity
38903897
# with a sequence of 3 or 4 numbers is resolved in
38913898
# favor of mapping, not rgb or rgba.
3892-
try:
3893-
c_array = np.asanyarray(c, dtype=float)
3894-
if c_array.size == x.size:
3895-
c = np.ma.ravel(c_array)
3896-
else:
3897-
# Wrong size; it must not be intended for mapping.
3898-
c_array = None
3899-
except ValueError:
3900-
# Failed to make a floating-point array; c must be color specs.
3899+
if c_none or co is not None:
39013900
c_array = None
3901+
else:
3902+
try:
3903+
c_array = np.asanyarray(c, dtype=float)
3904+
if c_array.size == x.size:
3905+
c = np.ma.ravel(c_array)
3906+
else:
3907+
# Wrong size; it must not be intended for mapping.
3908+
c_array = None
3909+
except ValueError:
3910+
# Failed to make a floating-point array; c must be color specs.
3911+
c_array = None
39023912

39033913
if c_array is None:
39043914
colors = c # must be acceptable as PathCollection facecolors

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,10 @@ def _setdefaults(self, defaults, *kwargs):
297297

298298
def _makeline(self, x, y, kw, kwargs):
299299
kw = kw.copy() # Don't modify the original kw.
300-
kwargs = kwargs.copy()
301-
default_dict = self._getdefaults(None, kw, kwargs)
302-
self._setdefaults(default_dict, kw, kwargs)
300+
kw.update(kwargs)
301+
default_dict = self._getdefaults(None, kw)
302+
self._setdefaults(default_dict, kw)
303303
seg = mlines.Line2D(x, y, **kw)
304-
self.set_lineprops(seg, **kwargs)
305304
return seg
306305

307306
def _makefill(self, x, y, kw, kwargs):

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,12 @@ def apply_callback(data):
175175
# Set / General
176176
(title, xmin, xmax, xlabel, xscale, ymin, ymax, ylabel, yscale,
177177
generate_legend) = general
178-
axes.set_xscale(xscale)
179-
axes.set_yscale(yscale)
178+
179+
if axes.get_xscale() != xscale:
180+
axes.set_xscale(xscale)
181+
if axes.get_yscale() != yscale:
182+
axes.set_yscale(yscale)
183+
180184
axes.set_title(title)
181185
axes.set_xlim(xmin, xmax)
182186
axes.set_xlabel(xlabel)

lib/matplotlib/lines.py

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,18 @@ def __init__(self, xdata, ydata,
333333
if solid_joinstyle is None:
334334
solid_joinstyle = rcParams['lines.solid_joinstyle']
335335

336+
if is_string_like(linestyle):
337+
ds, ls = self._split_drawstyle_linestyle(linestyle)
338+
if ds is not None and drawstyle is not None and ds != drawstyle:
339+
raise ValueError("Inconsistent drawstyle ({0!r}) and "
340+
"linestyle ({1!r})".format(drawstyle,
341+
linestyle)
342+
)
343+
linestyle = ls
344+
345+
if ds is not None:
346+
drawstyle = ds
347+
336348
if drawstyle is None:
337349
drawstyle = 'default'
338350

@@ -1004,6 +1016,38 @@ def set_linewidth(self, w):
10041016
self.stale = True
10051017
self._linewidth = w
10061018

1019+
def _split_drawstyle_linestyle(self, ls):
1020+
'''Split drawstyle from linestyle string
1021+
1022+
If `ls` is only a drawstyle default to returning a linestyle
1023+
of '-'.
1024+
1025+
Parameters
1026+
----------
1027+
ls : str
1028+
The linestyle to be processed
1029+
1030+
Returns
1031+
-------
1032+
ret_ds : str or None
1033+
If the linestyle string does not contain a drawstyle prefix
1034+
return None, otherwise return it.
1035+
1036+
ls : str
1037+
The linestyle with the drawstyle (if any) stripped.
1038+
'''
1039+
ret_ds = None
1040+
for ds in self.drawStyleKeys: # long names are first in the list
1041+
if ls.startswith(ds):
1042+
ret_ds = ds
1043+
if len(ls) > len(ds):
1044+
ls = ls[len(ds):]
1045+
else:
1046+
ls = '-'
1047+
break
1048+
1049+
return ret_ds, ls
1050+
10071051
def set_linestyle(self, ls):
10081052
"""
10091053
Set the linestyle of the line (also accepts drawstyles,
@@ -1056,15 +1100,9 @@ def set_linestyle(self, ls):
10561100
self._dashOffset = ls[0]
10571101
self._linestyle = "--"
10581102
return
1059-
1060-
for ds in self.drawStyleKeys: # long names are first in the list
1061-
if ls.startswith(ds):
1062-
self.set_drawstyle(ds)
1063-
if len(ls) > len(ds):
1064-
ls = ls[len(ds):]
1065-
else:
1066-
ls = '-'
1067-
break
1103+
ds, ls = self._split_drawstyle_linestyle(ls)
1104+
if ds is not None:
1105+
self.set_drawstyle(ds)
10681106

10691107
if ls in [' ', '', 'none']:
10701108
ls = 'None'

lib/matplotlib/tests/test_axes.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4386,6 +4386,25 @@ def test_axis_set_tick_params_labelsize_labelcolor():
43864386
assert axis_1.yaxis.majorTicks[0]._labelcolor == 'red'
43874387

43884388

4389+
@cleanup
4390+
def test_none_kwargs():
4391+
fig, ax = plt.subplots()
4392+
ln, = ax.plot(range(32), linestyle=None)
4393+
assert ln.get_linestyle() == '-'
4394+
4395+
4396+
@cleanup
4397+
def test_ls_ds_conflict():
4398+
assert_raises(ValueError, plt.plot, range(32),
4399+
linestyle='steps-pre:', drawstyle='steps-post')
4400+
4401+
4402+
@cleanup
4403+
def test_ls_ds_conflict():
4404+
assert_raises(ValueError, plt.plot, range(32),
4405+
linestyle='steps-pre:', drawstyle='steps-post')
4406+
4407+
43894408
@image_comparison(baseline_images=['date_timezone_x'], extensions=['png'])
43904409
def test_date_timezone_x():
43914410
# Tests issue 5575
@@ -4458,6 +4477,13 @@ def test_axisbelow():
44584477
ax.set_axisbelow(setting)
44594478

44604479

4480+
@cleanup
4481+
def test_large_offset():
4482+
fig, ax = plt.subplots()
4483+
ax.plot((1 + np.array([0, 1.e-12])) * 1.e27)
4484+
fig.canvas.draw()
4485+
4486+
44614487
if __name__ == '__main__':
44624488
import nose
44634489
import sys

lib/matplotlib/ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ def _compute_offset(self):
694694
# equal up to that precision?
695695
# Note: Internally using oom instead of 10 ** oom avoids some numerical
696696
# accuracy issues.
697-
oom_max = math.ceil(math.log10(abs_max))
697+
oom_max = np.ceil(math.log10(abs_max))
698698
oom = 1 + next(oom for oom in itertools.count(oom_max, -1)
699699
if abs_min // 10 ** oom != abs_max // 10 ** oom)
700700
if (abs_max - abs_min) / 10 ** oom <= 1e-2:

0 commit comments

Comments
 (0)