Skip to content
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

contour: map extended ranges to "under" and "over" values #1022

Merged
merged 4 commits into from Jul 24, 2012

Conversation

efiring
Copy link
Member

@efiring efiring commented Jul 17, 2012

Contourf was handling the extend kwarg by mapping the extended
ranges directly into the 0-1 normal colormap range, so that
using set_under and set_over had no effect; after this change, the
extended ranges are mapped outside the 0-1 range (after applying
the norm) so that the colors established by the set_under and set_over
colormap methods are used. By default, these are the end values of
the colormap. The new behavior matches the existing contourf documentation.

Fixed a bug in which the legend support for extend options was using the
wrong names for the options.

Contourf was handling the extend kwarg by mapping the extended
ranges directly into the 0-1 normal colormap range, so that
using set_under and set_over had no effect.
The legend support for extend options was also using the
wrong names for the options.
if self.extend in ('both', 'min'):
self.layers[0] = 0.5 * (self.vmin + self._levels[1])
self.layers[0] = -1e300
Copy link
Member

Choose a reason for hiding this comment

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

I hate magic numbers like this. Maybe we could use np.INF and np.NINF?

Copy link
Member Author

Choose a reason for hiding this comment

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

On 2012/07/20 5:20 PM, Benjamin Root wrote:

          if self.extend in ('both', 'min'):
  •            self.layers[0] = 0.5 \* (self.vmin + self._levels[1])
    
  •            self.layers[0] = -1e300
    

I hate magic numbers like this. Maybe we could use np.INF and np.NINF?

I thought of that, and may yet do so; but I wanted to get out a fix that
would work, and could not take time to test whether potentially
dangerous things like INF would cause trouble in practice. Note that mpl
has other somewhat arbitrary special numbers, because they make it work
most of the time.

Note that trying to simplify the code further by using np.inf a
few lines above, in self._levels, does not work; I'm not sure what
it breaks, but it definitely breaks something, probably in the
colorbar code.
efiring added a commit that referenced this pull request Jul 24, 2012
contour: map extended ranges to "under" and "over" values
@efiring efiring merged commit 967c15a into matplotlib:master Jul 24, 2012
efiring added a commit to efiring/matplotlib that referenced this pull request Aug 6, 2012


Filled contours now use more of the available colormap range than
previously.
@efiring efiring mentioned this pull request Aug 6, 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.

None yet

3 participants