Skip to content

BUG: raise on invalid colormap for older mpl #4231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ pandas 0.12
- Fixed bug in ``Series.where`` where broadcasting a single element input vector
to the length of the series resulted in multiplying the value
inside the input (:issue:`4192`)
- Fixed bug in plotting that wasn't raising on invalid colormap for
matplotlib 1.1.1 (:issue:`4215`)

pandas 0.11.0
=============
Expand Down
2 changes: 2 additions & 0 deletions doc/source/v0.12.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ Bug Fixes
argument in ``to_datetime`` (:issue:`4152`)
- Fixed bug in ``PandasAutoDateLocator`` where ``invert_xaxis`` triggered
incorrectly ``MilliSecondLocator`` (:issue:`3990`)
- Fixed bug in plotting that wasn't raising on invalid colormap for
matplotlib 1.1.1 (:issue:`4215`)

See the :ref:`full release notes
<release>` or issue tracker
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,8 +990,7 @@ def test_option_mpl_style(self):
pass

def test_invalid_colormap(self):
df = DataFrame(np.random.randn(500, 2), columns=['A', 'B'])

df = DataFrame(np.random.randn(3, 2), columns=['A', 'B'])
self.assertRaises(ValueError, df.plot, colormap='invalid_colormap')


Expand Down
7 changes: 5 additions & 2 deletions pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,17 @@
def _get_standard_kind(kind):
return {'density': 'kde'}.get(kind, kind)

def _get_standard_colors(num_colors=None, colormap=None,
color_type='default', color=None):
def _get_standard_colors(num_colors=None, colormap=None, color_type='default',
color=None):
import matplotlib.pyplot as plt

if color is None and colormap is not None:
if isinstance(colormap, basestring):
import matplotlib.cm as cm
cmap = colormap
colormap = cm.get_cmap(colormap)
if colormap is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you need a .format(colormap) here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gnarf

raise ValueError("Colormap {0} is not recognized".format(cmap))
colors = map(colormap, np.linspace(0, 1, num=num_colors))
elif color is not None:
if colormap is not None:
Expand Down