Skip to content

BF - Fix maximum colorbar extension. #931

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 1 commit into from
Jun 7, 2012

Conversation

ajdawson
Copy link
Contributor

@ajdawson ajdawson commented Jun 7, 2012

The maximum extension for colorbars was broken. This resulted in the maximum extension being the wrong color. This was introduced in commit b2f2ab9.

I traced this to a simple error when setting the number of boundaries. A check for 'min' or 'both' was used instead of a check for 'min' or 'max'.

@mdboom
Copy link
Member

mdboom commented Jun 7, 2012

Thanks for the patch. This fix already seems to be on the v1.1.x branch, but it didn't get correctly merged into master. Merging.

mdboom added a commit that referenced this pull request Jun 7, 2012
BF - Fix maximum colorbar extension.
@mdboom mdboom merged commit 6d9de3e into matplotlib:master Jun 7, 2012
@pelson
Copy link
Member

pelson commented Jun 7, 2012

Good spot. Do you have a couple of lines of code to reproduce? I would be good to add a test for this.

@pelson
Copy link
Member

pelson commented Jun 7, 2012

This fix already seems to be on the v1.1.x branch.

The bug was introduced by me (in #706) and integrated into master. Hence, v1.1.x is free of this issue.

@ajdawson If you have the code to show the problem it would be still useful, but I may put the test in in another PR.

@ajdawson
Copy link
Contributor Author

ajdawson commented Jun 7, 2012

@pelson
I came across this while trying to write some tests for PR #766. I was planning on drawing several plots including colorbars with and without the extensions, which would show up this issue also.

I was thinking something along the lines of this (but a bit more comprehensive):

import numpy as np
import matplotlib.pyplot as plt


x = y = np.linspace(-np.pi, np.pi, 100)
X, Y = np.meshgrid(x, y)
Z = np.cos(Y) * np.sin(X)

levels_linear = [-.75, -.5, -.25, -0., .25, .5, .75]
fill = plt.contourf(x, y, Z, levels_linear, extend='max')
plt.colorbar(fill, orientation='horizontal')

The maximum extension is blue if the bug is present, and red otherwise.

@ajdawson ajdawson deleted the cb-extension-fix branch July 18, 2013 14:17
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.

3 participants