8000 Change in behavior of axis.tick_left() with shared axes from 2.0 to 2.1 · Issue #9664 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Change in behavior of axis.tick_left() with shared axes from 2.0 to 2.1 #9664

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
mwaskom opened this issue Nov 2, 2017 · 9 comments · Fixed by #9670
Closed

Change in behavior of axis.tick_left() with shared axes from 2.0 to 2.1 #9664

mwaskom opened this issue Nov 2, 2017 · 9 comments · Fixed by #9670
Assignees
Milestone

Comments

@mwaskom
Copy link
mwaskom commented Nov 2, 2017

Bug report

Bug summary

Between 2.0 and 2.1, using tick_left() on the y axis of an inner panel of a plot with shared y axes makes the tips reappear.

Code for reproduction

import matplotlib.pyplot as plt
f, axes = plt.subplots(1, 2, sharey=True)
axes[1].yaxis.tick_left()

Actual outcome

On matplotlib 2.1:

mpl2 1

Expected outcome

On matplotlib 2.0:

mpl2 0

Matplotlib version

  • Operating system: macOS
  • Matplotlib version: 2.1
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX
  • Python version: 3.6
  • Jupyter version (if applicable): NA
  • Other libraries: NA

Matplotlib installed via conda.

@mwaskom
Copy link
Author
mwaskom commented Nov 2, 2017

(This behavior is not restricted to tick_left; it's also true of tick_bottom when the x axes are shared).

@afvincent
Copy link
Contributor
afvincent commented Nov 2, 2017

Thank you for issue report and the MWE :).

From git bisect, this behavior was changed by 2348584:

2348584dff8a6eb8e4c197b21d251a423d8126c3 is the first bad commit
commit 2348584dff8a6eb8e4c197b21d251a423d8126c3
Author: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date:   Sun May 28 16:41:53 2017 -0400

    Use (set_)tick_params more internally.

Attention @QuLogic (BTW: I would be inclined to milestone this for 2.1.1 if that's a very short fix)

@jklymak
Copy link
Member
jklymak commented Nov 2, 2017

I think 2348584 does the right thing in sharey (yaxis.set_tick_params(labelleft=False)) . What happened before with sharey is that the tick labels were still there but were made invisible.

The problem with yaxis.ticks_left() is that it does two things: puts the ticks on the left and says to label them (yaxis.set_tick_params(labelleft=True)). They didn't appear to be labeled before because sharey just made them invisible, but they were virtually there.

For now, I think a workaround is:

axes[1].yaxis.set_tick_params(left=True)

and maybe the proper solution to the OPs issue is better documentation of ticks_left()?

@mwaskom
Copy link
Author
mwaskom commented Nov 2, 2017

This new behavior causes some major problems for multi-panel plots in seaborn. I can make changes going forward, but it's going to be an issue that is very difficult to work around for people who are updating asynchronously.

@jklymak
Copy link
Member
jklymak commented Nov 2, 2017

I agree the API shouldn't change w/o notice.

The question is do we want to change ticks_left to just do set_tick_params(which='both', left=True, right=False)? and leave the labelRight and labelLeft untouched? That'd give you back the functionality you had before. However, that would be an API change for people who (for whatever reason) expect ticks_left to redraw ticks that had been set with labelleft=False.

@jklymak jklymak changed the title Change in behavior of inner ticklabels with shared axes from 2.0 to 2.1 Change in behavior of axis.tick_left() with shared axes from 2.0 to 2.1 Nov 2, 2017
@jklymak jklymak self-assigned this Nov 3, 2017
@jklymak
Copy link
Member
jklymak commented Nov 3, 2017

@mwaskom Did you have the ability to try #9670 and make sure it works in general for you?

@mwaskom
Copy link
Author
mwaskom commented Nov 3, 2017

@jklymak No, I'm not set up to build matplotlib locally

@mwaskom
Copy link
Author
mwaskom commented Jun 14, 2018

Following up on this: I tried @jklymak's suggestion of using ax.yaxis.set_tick_params. However, I can't fully replicate what (e.g.) ax.yaxis.tick_right is doing because it's checking private attributes to know whether to set labelleft/labelright.

        label = True
        if 'label1On' in self._major_tick_kw:
            label = (self._major_tick_kw['label1On']
                     or self._major_tick_kw['label2On'])

So I end up running right into the original problem in this thread.

Given that, if there's no public way to determine whether tick labels are on, I'd like to ask that you please maintain stability in the tick_{left,right,bottom,top} convenience methods.

Thanks.

@mwaskom
Copy link
Author
mwaskom commented Jun 24, 2018

Given that, if there's no public way to determine whether tick labels are on, I'd like to ask that you please maintain stability in the tick_{left,right,bottom,top} convenience methods.

Actually I ended up needing to solve this problem for another reason, and it does turn out to possible (if a bit roundabout), so I retract this statement and request.

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

Successfully merging a pull request may close this issue.

3 participants
0