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

Infinite Loop: LogLocator Colorbar & update_ticks #6057

Closed
ocehugo opened this issue Feb 24, 2016 · 5 comments
Closed

Infinite Loop: LogLocator Colorbar & update_ticks #6057

ocehugo opened this issue Feb 24, 2016 · 5 comments
Milestone

Comments

@ocehugo
Copy link

ocehugo commented Feb 24, 2016

  • [ 1.5.1,3.5.1,OSX] Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
  • [pip ] How did you install Matplotlib and Python (pip, anaconda, from source ...)
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.colors import LogNorm
import numpy as np
from matplotlib.mlab import bivariate_normal


N = 100
X, Y = np.mgrid[-3:3:complex(0, N), -2:2:complex(0, N)]

# A low hump with a spike coming out of the top right.
# Needs to have z/colour axis on a log scale so we see both hump and spike.
# linear scale only shows the spike.
Z1 = bivariate_normal(X, Y, 0.1, 0.2, 1.0, 1.0) + 0.1 * bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)

plt.subplot(2, 1, 1)
plt.pcolor(X, Y, Z1, norm=LogNorm(vmin=Z1.min(), vmax=Z1.max()), cmap='PuBu_r')
cbar = plt.colorbar()
cbar.locator = mpl.ticker.LogLocator(numticks=1)
cbar.update_ticks()

The code above follow from the pcolor_log.py example.

PS: I would be great if mpl include a LogMaxNLocator just like the linear one.

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Feb 25, 2016
@tacaswell
Copy link
Member

The simple 'fix' is that to get what you want with numticks=1 I think you really want to pass numticks=2

@ocehugo
Copy link
Author

ocehugo commented Feb 25, 2016

I know, but it's easy to forgot that the numticks argument is in fact numticks-1.

No one likes to restart their notebooks because of a colorbar hehe .

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Feb 25, 2016
@tacaswell
Copy link
Member

Well, the solution I am looking at will just raise instead of infinite loop which is slightly better.

@yongzhez
Copy link
Contributor

yongzhez commented Mar 2, 2016

So I was wondering what would be a preferred solution. I would be guessing that there's a better form of validation for input that would filter out ALL possible unwanted ticker values? I apologize for the pull request since I didn't see that you already added a fix similar to mine.

@tacaswell
Copy link
Member

I am hesitant to invest too much in validation of this sort of thing right now. On of the mid-term (by summer) goals is to get the entire library traitlet-ified which will provide much greater more flexible validation for one giant upfront cost.

@QuLogic QuLogic modified the milestones: 1.5.2 (Critical bug fix release), 2.0.1 (next bug fix release) May 16, 2016
tacaswell added a commit to tacaswell/matplotlib that referenced this issue May 22, 2016
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

No branches or pull requests

4 participants