Skip to content

Extra ticks at an extended part of colorbar #19543

Closed
@yoichi-kazama

Description

@yoichi-kazama

Bug report

Extra minorticks appear at an extended part of colorbar with ticks=LogLocator(numticks=10, subs='all').

Code for reproduction

%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
from matplotlib.ticker import LogLocator

v = np.geomspace(1e0, 1e4, num=3 * 4).reshape(3, 4)

fig, axs = plt.subplots(figsize=(6, 2))
pc = axs.pcolormesh(v, norm=LogNorm())
fig.colorbar(pc, extend='both')

fig, axs = plt.subplots(figsize=(6, 2))
pc = axs.pcolormesh(v, norm=LogNorm())
fig.colorbar(pc, extend='both', ticks=LogLocator(numticks=10))

fig, axs = plt.subplots(figsize=(6, 2))
pc = axs.pcolormesh(v, norm=LogNorm())
fig.colorbar(pc, extend='both', ticks=LogLocator(numticks=10, subs='all'))

Actual outcome

screenshot 2021-02-19 153003

Expected outcome

Minor ticks appear only at the body of the colorbar.

Probably this is not a right usage for the subs option, but I just want to show minor ticks, which by default are not shown for a short colorbar.

Matplotlib version

  • Operating system:
  • Matplotlib version: 3.3.4
  • Matplotlib backend: module://ipykernel.pylab.backend_inline
  • Python version: 3.7.9
  • Jupyter version (if applicable): Jupyterlab 3.0.8
  • Other libraries:

All installed by conda install -c conda-forge ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions