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

[Bug]: CbarAxesBase.toggle_label doesn't seem to work properly #23595

Closed
oscargus opened this issue Aug 10, 2022 · 10 comments · Fixed by #25884
Closed

[Bug]: CbarAxesBase.toggle_label doesn't seem to work properly #23595

oscargus opened this issue Aug 10, 2022 · 10 comments · Fixed by #25884
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! topic: mpl_toolkit
Milestone

Comments

@oscargus
Copy link
Contributor

oscargus commented Aug 10, 2022

Bug summary

It appears as if CbarAxesBase.toggle_label and therefore, maybe, SimpleAxisArtist.toggle and possibly something else does not work as expected.

Probably related to the colorbar rewrite?

Code for reproduction

https://matplotlib.org/stable/gallery/axes_grid1/demo_axes_grid.html

Actual outcome

The two middle figures have visible tick labels for the color bar.

Expected outcome

No visible tick labels.

Additional information

There seems to be some sort of mismatch between the _axisnum property and the location of the labels. It seems to work if the labels are located at the same side as the colorbar, i.e., right and bottom.

Operating system

Arch

Matplotlib Version

3.5.2 and main

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

git checkout

@oscargus oscargus added Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! labels Aug 30, 2022
@oscargus
Copy link
Contributor Author

oscargus commented Aug 30, 2022

Marking as good first issue, but medium as it requires digging in how to modify the calls here (and possibly deprecating/replacing any other methods that may be affected).

These are the lines that are not working properly:

def toggle_label(self, b):
axis = self.axis[self.orientation]
axis.toggle(ticklabels=b, label=b)

@vorbrodt
Copy link

vorbrodt commented Sep 1, 2022

I would like to be assigned to this issue.

@oscargus
Copy link
Contributor Author

oscargus commented Sep 1, 2022

@vorbrodt Thanks for your interest! We do typically not assign persons to issues, but feel free to work on it anyway. Your note will most likely lead to people focusing on other issues instead,

@oscargus
Copy link
Contributor Author

oscargus commented Sep 1, 2022

Just noting that there are some other demos that also use toggle_label, where it appears as the output is not really as expected:

https://matplotlib.org/stable/gallery/axes_grid1/demo_axes_grid2.html
https://matplotlib.org/stable/gallery/axes_grid1/demo_edge_colorbar.html

Going back to 3.4.3, they probably are as expected:
https://matplotlib.org/3.4.3/gallery/axes_grid1/demo_axes_grid2.html
https://matplotlib.org/3.4.3/gallery/axes_grid1/demo_edge_colorbar.html
https://matplotlib.org/3.4.3/gallery/axes_grid1/demo_axes_grid.html

(Although demo_edge_colorbar.html seems to be missing a label on the left figure in all available versions of the documentation...)

@vorbrodt
Copy link

vorbrodt commented Sep 5, 2022

Okay, I see. I'll be working on this issue.

@oscargus
Copy link
Contributor Author

The problem seems related to self._axisnum having the wrong value so

if _ticklabels is not None:
tickparam = {f"label{self._axisnum}On": _ticklabels}
self._axis.set_tick_params(**tickparam)

is not correct.

@xtanion
Copy link
Contributor

xtanion commented Mar 9, 2023

Hi @oscargus, I was trying to fix this issue...maybe self._axisnum isn't incorrect (As it is 1 for bottom and left axes & 2 for top & right). The issue seems to be related with the colorbar having two labels when it's set to top and left. I managed to solve it by disabling the bottom and right axes for both cases. Is it the expected outcome?
Figure_1

@anntzer
Copy link
Contributor

anntzer commented May 13, 2023

Bisects to #20054.

@jklymak
Copy link
Member

jklymak commented May 13, 2023

I don't quite understand how this can bisect to #20054? That PR is for the normal colorbar axes, not the CbarAxes?

@anntzer
Copy link
Contributor

anntzer commented May 13, 2023

cbaraxes ultimately uses normal colorbars (it's just an axes subclass that adds a colorbar() method on the axes to draw colorbars on that axes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! topic: mpl_toolkit
Projects
None yet
6 participants