Skip to content

Color bar has multiple labels for 0 if matplotlib.colors.SymLogNorm is used #10122

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

Closed
tillahoffmann opened this issue Dec 28, 2017 · 1 comment · Fixed by #10129
Closed

Color bar has multiple labels for 0 if matplotlib.colors.SymLogNorm is used #10122

tillahoffmann opened this issue Dec 28, 2017 · 1 comment · Fixed by #10129
Milestone

Comments

@tillahoffmann
Copy link
Contributor

Bug report

Bug summary

The color bar has multiple labels with the value 0 if matplotlib.colors.SymLogNorm is used leading to a "bold-looking" label.

Code for reproduction

from matplotlib import pyplot as plt
import matplotlib as mpl

fig, axes = plt.subplots(1, 2, True, True)

for i, ax in enumerate(axes): 
    im = ax.imshow([[0]], norm=mpl.colors.SymLogNorm(1e-5, vmin=-1, vmax=1))
    cb = plt.colorbar(im, ax=ax)

# Clean up the labels
zero_labelled = False
for label in cb.ax.yaxis.get_ticklabels():
    if label.get_text() == r'$\mathdefault{0}$':
        if zero_labelled:
            label.set_visible(False)
        zero_labelled = True

Actual outcome on the left, expected outcome on the right

image

Matplotlib version

  • Operating system: Linux 1061836d2c20 4.9.49-moby Fix autofmt_xdate() when using in conjunction with twinx() #1 SMP Fri Dec 8 13:40:02 UTC 2017 x86_64 GNU/Linux
  • Matplotlib version: 2.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.6.3
  • Jupyter version (if applicable): 4.4.0
  • Other libraries: numpy (1.13.3)

All libraries were installed using pip in a docker image derived from python:3.

@tillahoffmann
Copy link
Contributor Author

Thank you for the fix @Raab70.

@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants