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

Skip to content

Commit cf83cd5

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
Conflicts: doc/users/whats_new.rst - kept headings from 2.x lib/matplotlib/_color_data.py - kept 2.x version lib/matplotlib/colors.py - kept 2.x version
2 parents 54b120f + f63ae7a commit cf83cd5

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

doc/users/whats_new.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ removed. Instead, images will obey the transform of the axes on which
213213
they are drawn.
214214

215215
Non-linear scales on image plots
216-
````````````````````````````````
216+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
217217

218218
:func:`imshow` now draws data at the requested points in data space after the
219219
application of non-linear scales.
@@ -222,8 +222,6 @@ The image on the left demonstrates the new, correct behavior.
222222
The old behavior can be recreated using :func:`pcolormesh` as
223223
demonstrated on the right.
224224

225-
Non-linear scale example
226-
````````````````````````
227225

228226
.. plot::
229227

lib/matplotlib/_color_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
# These colors are from Tableau
19-
TABLEAU_COLORS = OrderedDict((
19+
TABLEAU_COLORS = (
2020
('blue', '#1f77b4'),
2121
('orange', '#ff7f0e'),
2222
('green', '#2ca02c'),
@@ -26,12 +26,12 @@
2626
('pink', '#e377c2'),
2727
('gray', '#7f7f7f'),
2828
('olive', '#bcbd22'),
29-
('cyan', '#17becf'))
29+
('cyan', '#17becf'),
3030
)
3131

3232
# Normalize name to "tab:<name>" to avoid name collisions.
3333
TABLEAU_COLORS = OrderedDict(
34-
('tab:' + name, value) for name, value in TABLEAU_COLORS.items())
34+
('tab:' + name, value) for name, value in TABLEAU_COLORS)
3535

3636
# This mapping of color names -> hex values is taken from
3737
# a survey run by Randel Monroe see:

lib/matplotlib/colors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ def to_hex(c, keep_alpha=False):
259259
### Backwards-compatible color-conversion API
260260

261261
cnames = CSS4_COLORS
262-
COLOR_NAMES = {'xkcd': XKCD_COLORS, 'css4': CSS4_COLORS, 'tc': TABLEAU_COLORS}
263262
hexColorPattern = re.compile("\A#[a-fA-F0-9]{6}\Z")
264263

265264

lib/matplotlib/image.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,11 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
368368
# values to carry the over/under/bad information
369369
rgba = np.empty((A.shape[0], A.shape[1], 4), dtype=A.dtype)
370370
rgba[..., 0] = A # normalized data
371-
rgba[..., 1] = A < 0 # under data
372-
rgba[..., 2] = A > 1 # over data
371+
# this is to work around spurious warnings coming
372+
# out of masked arrays.
373+
with np.errstate(invalid='ignore'):
374+
rgba[..., 1] = A < 0 # under data
375+
rgba[..., 2] = A > 1 # over data
373376
rgba[..., 3] = ~A.mask # bad data
374377
A = rgba
375378
output = np.zeros((out_height, out_width, 4),

lib/matplotlib/tests/test_image.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import six
55
import io
66
import os
7+
import warnings
78

89
from nose.plugins.attrib import attr
910

@@ -746,5 +747,13 @@ def test_imshow_endianess():
746747
ax2.imshow(Z.astype('>f8'), **kwargs)
747748

748749

750+
@cleanup
751+
def test_imshow_no_warn_invalid():
752+
with warnings.catch_warnings(record=True) as warns:
753+
warnings.simplefilter("always")
754+
plt.imshow([[1, 2], [3, np.nan]])
755+
assert len(warns) == 0
756+
757+
749758
if __name__ == '__main__':
750759
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)