Skip to content

Full support for string cmaps. #951

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 2 commits into from
Jun 21, 2012
Merged

Conversation

pelson
Copy link
Member

@pelson pelson commented Jun 16, 2012

This PR allows users to always specify names of registered cmaps where cmap is an argument to an axes or figure method.

else:
raise ValueError("Colormap %s is not recognized" % name)

raise ValueError("Colormap %s is not recognized" % name)
Copy link
Member Author

Choose a reason for hiding this comment

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

Note the change in scope. This fixes the obtuse message:

>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> plt.imshow(np.arange(12).reshape(3, 4), cmap='hots')
<matplotlib.image.AxesImage object at 0x25265d0>
>>> plt.show()
Traceback (most recent call last):
  File "matplotlib/backends/backend_gtk.py", line 423, in expose_event
    self._render_figure(self._pixmap, w, h)
  File "matplotlib/backends/backend_gtkagg.py", line 75, in _render_figure
    FigureCanvasAgg.draw(self)
  File "matplotlib/backends/backend_agg.py", line 433, in draw
    self.figure.draw(self.renderer)
  File "matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "matplotlib/figure.py", line 925, in draw
    func(*args)
  File "matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "matplotlib/axes.py", line 1998, in draw
    a.draw(renderer)
  File "matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "matplotlib/image.py", line 359, in draw
    im = self.make_image(renderer.get_image_magnification())
  File "matplotlib/image.py", line 579, in make_image
    transformed_viewLim)
  File "matplotlib/image.py", line 202, in _get_unsampled_image
    x = self.to_rgba(self._A, bytes=False)
  File "matplotlib/cm.py", line 241, in to_rgba
    x = self.cmap(x, alpha=alpha, bytes=bytes)
TypeError: 'NoneType' object is not callable

@pelson
Copy link
Member Author

pelson commented Jun 20, 2012

This is quite a trivial change, so unless anyone objects, I will merge in 24hrs.

@efiring
Copy link
Member

efiring commented Jun 20, 2012

On 06/20/2012 12:38 AM, Phil Elson wrote:

This is quite a trivial change, so unless anyone objects, I will merge in 24hrs.

All good.

Eric


Reply to this email directly or view it on GitHub:
#951 (comment)

pelson added a commit that referenced this pull request Jun 21, 2012
Contour and streamplot support for cmaps passed by name.
@pelson pelson merged commit 2b4ab26 into matplotlib:master Jun 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants