Skip to content

set_ylabel does not work as expected with SubplotZero #7617

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
tacaswell opened this issue Dec 12, 2016 · 5 comments · Fixed by #24085
Closed

set_ylabel does not work as expected with SubplotZero #7617

tacaswell opened this issue Dec 12, 2016 · 5 comments · Fixed by #24085

Comments

@tacaswell
Copy link
Member

Discovered as part of #7489

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.axislines import SubplotZero

fig = plt.figure()
ax = SubplotZero(fig, 111)
_ = fig.add_subplot(ax)


for direction in ["xzero", "yzero"]:
    ax.axis[direction].set_visible(True)
    ax.axis[direction].set_axisline_style("->")
    # Set outward ticks
    ax.axis[direction].major_ticks.set_tick_out(True)
    ax.axis[direction].minor_ticks.set_tick_out(True)

ax.axis["yzero"].set_axis_direction("left")

plt.plot([0,1], [0,1], c="blue", lw=2)
plt.xlabel('x')
plt.ylabel('y')

so

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Dec 12, 2016
@AndreWin
Copy link

There is workaround from here:

ax.axis['xzero'].set_label("x")
ax.axis['yzero'].set_label("y")

@jacob-pecile
Copy link

@tacaswell is it only issue that the label on the extra y axis is incorrect, or should the axis of the original Axes be overwritten with the new one created using the AxisArtist.

Sorry if this is obvious, I'm wondering if the extra set of axes drawn are expected or not

@tacaswell
Copy link
Member Author

I am not sure what the 'should' here is. plt.ylabel not working is very surprising, that is definitely a bug. However exactly how SubplotZero manages it's internals is not something I have clear in my head.

I would say the two pieces of work here are:

  • make plt.ylabel 'do the right thing'
  • make sure that what ever SubplotZero is doing is will documented.

@jacob-pecile
Copy link

Oh okay I see. What I was essentially asking is if the expected result is the same figure in the original post but with a y instead of an x on the y axis, or if there was more to it.

@tacaswell
Copy link
Member Author

Yes, I think that is the core of it (plt.ylabel should work).

c3liujia pushed a commit to c3liujia/matplotlib that referenced this issue Apr 12, 2017
@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.2 (next feature release) Oct 9, 2017
oscargus added a commit to oscargus/matplotlib that referenced this issue Nov 24, 2022
oscargus added a commit to oscargus/matplotlib that referenced this issue Nov 24, 2022
oscargus added a commit to oscargus/matplotlib that referenced this issue Dec 3, 2022
oscargus added a commit to oscargus/matplotlib that referenced this issue Dec 8, 2022
oscargus added a commit to oscargus/matplotlib that referenced this issue Dec 8, 2022
oscargus added a commit to oscargus/matplotlib that referenced this issue Dec 15, 2022
@QuLogic QuLogic modified the milestones: future releases, v3.7.0 Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants