Skip to content

Commit

Permalink
Merge remote-tracking branch 'matplotlib/v2.x'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tacaswell committed Jan 16, 2017
2 parents 54b120f + f63ae7a commit cf83cd5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 1 addition & 3 deletions doc/users/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ removed. Instead, images will obey the transform of the axes on which
they are drawn.

Non-linear scales on image plots
````````````````````````````````
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Non-linear scale example
````````````````````````

.. plot::

Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/_color_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


# These colors are from Tableau
TABLEAU_COLORS = OrderedDict((
TABLEAU_COLORS = (
('blue', '#1f77b4'),
('orange', '#ff7f0e'),
('green', '#2ca02c'),
Expand All @@ -26,12 +26,12 @@
('pink', '#e377c2'),
('gray', '#7f7f7f'),
('olive', '#bcbd22'),
('cyan', '#17becf'))
('cyan', '#17becf'),
)

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

# This mapping of color names -> hex values is taken from
# a survey run by Randel Monroe see:
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ def to_hex(c, keep_alpha=False):
### Backwards-compatible color-conversion API

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


Expand Down
7 changes: 5 additions & 2 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,11 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
# values to carry the over/under/bad information
rgba = np.empty((A.shape[0], A.shape[1], 4), dtype=A.dtype)
rgba[..., 0] = A # normalized data
rgba[..., 1] = A < 0 # under data
rgba[..., 2] = A > 1 # over data
# this is to work around spurious warnings coming
# out of masked arrays.
with np.errstate(invalid='ignore'):
rgba[..., 1] = A < 0 # under data
rgba[..., 2] = A > 1 # over data
rgba[..., 3] = ~A.mask # bad data
A = rgba
output = np.zeros((out_height, out_width, 4),
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import six
import io
import os
import warnings

from nose.plugins.attrib import attr

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


@cleanup
def test_imshow_no_warn_invalid():
with warnings.catch_warnings(record=True) as warns:
warnings.simplefilter("always")
plt.imshow([[1, 2], [3, np.nan]])
assert len(warns) == 0


if __name__ == '__main__':
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 comments on commit cf83cd5

Please sign in to comment.