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

Skip to content

Colorbar with imshow(logNorm) shows unexpected minor ticks #8307

Closed
@billtau

Description

@billtau

Bug report

Bug summary

When using colorbar with imshow(image, norm=LogNorm()), the produced colorbar automatically adds minorticks, and cannot be turned off with cbar.ax.minorticks_off(). Also the font of the tick label is not the same as the font set in matplotlibrc.

Code for reproduction

# This is modified from an example in matplotlib gallery.

import matplotlib.pyplot as plt
import numpy as np
from numpy import ma
from matplotlib import colors, ticker, cm
from matplotlib.mlab import bivariate_normal

N = 100
x = np.linspace(-3.0, 3.0, N)
y = np.linspace(-2.0, 2.0, N)

X, Y = np.meshgrid(x, y)

z = (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))

z = ma.masked_where(z <= 0, z)

fig, ax = plt.subplots()

from matplotlib.colors import LogNorm

cs = ax.imshow(z,norm=LogNorm())

cbar = fig.colorbar(cs)

cbar.ax.minorticks_off()

plt.show()

Actual outcome

screen shot 2017-03-16 at 9 02 34 pm

Expected outcome

I would expect the colorbar to not have minorticks and to use the same font as other tick labels (I set font to be Arial in matplotlibrc).

Matplotlib version

  • Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)

2.0.0_1, OSX

  • How did you install Matplotlib and Python (pip, anaconda, from source ...)
    Macports

Edit by @afvincent: removed the unnecessary instructions coming from the bug report template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions