Skip to content

Commit 8a0c2cc

Browse files
committed
Merge pull request #4231 from cpcloud/matplotlib-invalid-colomap-test
BUG: raise on invalid colormap for older mpl
2 parents 0e80039 + 4e48e52 commit 8a0c2cc

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ pandas 0.12
331331
- Fixed bug in ``Series.where`` where broadcasting a single element input vector
332332
to the length of the series resulted in multiplying the value
333333
inside the input (:issue:`4192`)
334+
- Fixed bug in plotting that wasn't raising on invalid colormap for
335+
matplotlib 1.1.1 (:issue:`4215`)
334336

335337
pandas 0.11.0
336338
=============

doc/source/v0.12.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ Bug Fixes
463463
argument in ``to_datetime`` (:issue:`4152`)
464464
- Fixed bug in ``PandasAutoDateLocator`` where ``invert_xaxis`` triggered
465465
incorrectly ``MilliSecondLocator`` (:issue:`3990`)
466+
- Fixed bug in plotting that wasn't raising on invalid colormap for
467+
matplotlib 1.1.1 (:issue:`4215`)
466468

467469
See the :ref:`full release notes
468470
<release>` or issue tracker

pandas/tests/test_graphics.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,7 @@ def test_option_mpl_style(self):
990990
pass
991991

992992
def test_invalid_colormap(self):
993-
df = DataFrame(np.random.randn(500, 2), columns=['A', 'B'])
994-
993+
df = DataFrame(np.random.randn(3, 2), columns=['A', 'B'])
995994
self.assertRaises(ValueError, df.plot, colormap='invalid_colormap')
996995

997996

pandas/tools/plotting.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,17 @@
9191
def _get_standard_kind(kind):
9292
return {'density': 'kde'}.get(kind, kind)
9393

94-
def _get_standard_colors(num_colors=None, colormap=None,
95-
color_type='default', color=None):
94+
def _get_standard_colors(num_colors=None, colormap=None, color_type='default',
95+
color=None):
9696
import matplotlib.pyplot as plt
9797

9898
if color is None and colormap is not None:
9999
if isinstance(colormap, basestring):
100100
import matplotlib.cm as cm
101+
cmap = colormap
101102
colormap = cm.get_cmap(colormap)
103+
if colormap is None:
104+
raise ValueError("Colormap {0} is not recognized".format(cmap))
102105
colors = map(colormap, np.linspace(0, 1, num=num_colors))
103106
elif color is not None:
104107
if colormap is not None:

0 commit comments

Comments
 (0)