Skip to content
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

colorbar minorticks (possibly release critical for 3.0) #12095

Closed
pharshalp opened this issue Sep 11, 2018 · 2 comments
Closed

colorbar minorticks (possibly release critical for 3.0) #12095

pharshalp opened this issue Sep 11, 2018 · 2 comments

Comments

@pharshalp
Copy link
Contributor

pharshalp commented Sep 11, 2018

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

@jklymak
Copy link
Member

jklymak commented Sep 11, 2018

Thanks @pharshalp that is just a floating point tolerance issue that I wasn't taking into account. Fixed now on #12099

Note I think this fix should be made for all ticks: see discsusion at bottom of #11004

@tacaswell tacaswell added this to the v3.0 milestone Sep 15, 2018
@tacaswell
Copy link
Member

Closed by #12099

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants