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

_DummyAxis needs a __name__ attribute for ScalarFormatter #17624

Closed
efiring opened this issue Jun 13, 2020 · 1 comment · Fixed by #17625
Closed

_DummyAxis needs a __name__ attribute for ScalarFormatter #17624

efiring opened this issue Jun 13, 2020 · 1 comment · Fixed by #17625
Assignees
Milestone

Comments

@efiring
Copy link
Member

efiring commented Jun 13, 2020

Bug report

Bug summary

ScalarFormatter.format_data_short(x) uses self.axis__name__ to get xaxis or yaxis info. If the instance was made with a _DummyAxis instance, however, it fails.
Code for reproduction
See next comment.
Matplotlib version
Master (3.2.1.post2853+g15c0d7c39)

@efiring
Copy link
Member Author

efiring commented Jun 13, 2020

This bug is triggered in normal usage by the following, if you move the cursor over the image:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors

z = np.arange(9).reshape((3, 3)).astype(float)
fig, ax = plt.subplots()
im = ax.imshow(z)
cbar = fig.colorbar(im, ax=ax, boundaries=[2, 4, 6])
plt.show()

In this case, the boundaries kwarg is causing the use of a _DummyAxis, which lacks a __name__ attribute.
The problem was noticed while looking at #17453.

@efiring efiring self-assigned this Jun 13, 2020
@efiring efiring changed the title ScalarFormatter should not require an Axis with a __name__ _DummyAxis needs a __name__ attribute for ScalarFormatter Jun 13, 2020
@QuLogic QuLogic added this to the v3.3.0 milestone Jun 15, 2020
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