Skip to content

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

Closed

Description

@lamorton

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.

Activity

  1. phobson commented on Mar 21, 2017

    @phobson
    Member

    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()
  2. billtau commented on May 5, 2017

    @billtau

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

  3. afvincent commented on Oct 23, 2017

    @afvincent
    Contributor

    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 😈...

  4. added this to the milestone on Oct 23, 2017
  5. Dih5 commented on Mar 23, 2018

    @Dih5

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

  6. jklymak commented on Mar 23, 2018

    @jklymak
    Member

    Great!

  7. modified the milestones: , on Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions