Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Minor ticks on log-scale colorbar are not cleared #8358

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

Closed
lamorton opened this issue Mar 21, 2017 · 5 comments
Closed

Minor ticks on log-scale colorbar are not cleared #8358

lamorton opened this issue Mar 21, 2017 · 5 comments

Comments

@lamorton
Copy link

lamorton commented Mar 21, 2017

Bug report

Bug summary

  • Using pcolormesh with logarithmic color scale and minor ticks enabled results in a cluttered-looking set of minor ticks, apparently because the linear ticks are not removed, just overplotted with the log scale ones.

Code for reproduction

import numpy
from matplotlib.colors import LogNorm
from matplotlib.pyplot import pcolormesh, colorbar, rcParams
rcParams['xtick.minor.visible']=True
rcParams['ytick.minor.visible']=True
data=numpy.random.random((10,12))*100.0+0.1 
pcolormesh(data,norm=LogNorm())
colorbar()

Actual outcome
lognormmess

Expected outcome

  • Expect that the colobar minor ticks would appear logarithmically.

Version Info
Platform: GNU/Linux 2.6.32-642.11.1.el6.x86_64
Python: 2.7.13 |Anaconda custom (64-bit)
IPython: 5.2.2
Matplotib: 2.0.0

All python components installed via Anaconda.

@phobson
Copy link
Member

phobson commented Mar 21, 2017

Thanks for the detailed report. I can reproduce this.

For the time being, here's how you can somewhat work around this:

import numpy
from matplotlib.colors import LogNorm
from matplotlib.pyplot import pcolormesh,colorbar, rcParams
rcParams['xtick.minor.visible']=True
rcParams['ytick.minor.visible']=True
data = numpy.random.random((10,12))*100.0+0.1 
img = pcolormesh(data,norm=LogNorm())
cbar = colorbar(img)
cbar.ax.minorticks_off()

@billtau
Copy link

billtau commented May 5, 2017

I just upgraded to matplotlib 2.0.1, and I still see the behavior described by PO.

@afvincent
Copy link
Contributor

afvincent commented Oct 23, 2017

FWIW, this issue is still present on Matplotlib 2.1 (and master 2.1.0.post357+g075618bb4). (@phobson's workaround is still fine though)

Basically, the issue seems to be that when using a logarithmic-locator like LogLocator or SymmetricalLogLocator, the minor ticks are emulated with non-labelled major ticks, while the minor locator of the colorbar Axes remains AutoMinorLocator but is not visible by default. Except for example when one asked to make every minor tick visible through rcParams tweaking 😈...

@afvincent afvincent added this to the v2.2 milestone Oct 23, 2017
@Dih5
Copy link

Dih5 commented Mar 23, 2018

This has been fixed by #9903.
Here is a figure obtained right now using the master branch:
figure_1

@jklymak
Copy link
Member

jklymak commented Mar 23, 2018

Great!

@jklymak jklymak closed this as completed Mar 23, 2018
@QuLogic QuLogic modified the milestones: needs sorting, v3.0 Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants