Skip to content

colorbar minorticks (possibly release critical for 3.0) #12095

Closed
@pharshalp

Description

@pharshalp

Bug report

Bug summary

NOTE: This is only applicable for 3.0 as cbar.minorticks_on() is introduced in 3.0 only.

When the minorticks are turned on for a colorbar, a minor tick is found to be missing from the vmax end of the colorbar (the weird part is, this doesn't happen for all values of vmax).

@jklymak can you please have a look?

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

# setup some generic data
N = 37
x, y = np.mgrid[:N, :N]
Z = (np.cos(x*0.2) + np.sin(y*0.3))

fig, ax= plt.subplots(figsize=(4, 3))

im = ax.imshow(Z, cmap='RdBu', vmin=-1.2, vmax=1.2, interpolation='none')
cbar = fig.colorbar(im, ax=ax, extend='both')
cbar.minorticks_on()
plt.show()

Actual outcome

The minor tick corresponding to the value +1.2 is missing!

figure_1

Even if I increase the vmax by 10**-16 I get the same result i.e.

im = ax.imshow(Z, cmap='RdBu', vmin=-1.2, vmax=1.2+10**-16, interpolation='none')

Expected outcome
I get the expected outcome by increasing the vmax by 10**-15

im = ax.imshow(Z, cmap='RdBu', vmin=-1.2, vmax=1.2+10**-15, interpolation='none')

figure_2

This issue doesn't show up if I use vmax=1.3

im = ax.imshow(Z, cmap='RdBu', vmin=-1.2, vmax=1.3, interpolation='none')

figure_10

Matplotlib version

  • Operating system: Mac OS 10.13.6
  • Matplotlib version: '3.0.0rc2.post25+g68845f8e5'
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: Python 3.7.0

P.S. I realized this when I was looking at the modification I made to https://github.com/matplotlib/matplotlib/blob/master/examples/color/colorbar_basics.py to show off cbar.minorticks_on()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions