GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Second y-axis does not scale correctly when using zoom tool · Issue #9616 · matplotlib/matplotlib

Second y-axis does not scale correctly when using zoom tool #9616

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Second y-axis does not scale correctly when using zoom tool#9616
Copy link

Description

@DietBru
DietBru
opened on Oct 29, 2017
Issue body actions

Hello,
when making a plot with two differently scaled y-axes by following this example, the second scale becomes incorrect after using the zoom tool (see example below). Interestingly, reading the ylim values (see example below) yields in the expected results. Using ax.set_ylim() and using the paning tool do not show this behavior.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.set(title="Two y-scales", ylabel="x / m")
# right ax:
axr = ax.twinx()
axr.set_ylabel("x / cm")


def track_yax(ax_):
    """Syncronize second y-axis with first axis. """
    y1, y2 = ax.get_ylim()
    axr.set_ylim(100*y1, y2*100)
    # axr.figure.canvas.draw() # does not make a difference
    yr1, yr2 = axr.get_ylim()
    print(f"Lower: {y1:+.5g} -> {yr1:+.5g}\t Upper: {y2:+.5g} -> {yr2:+.5g}")


# automatically update ylim of ax2 when ylim of ax1 changes.
ax.callbacks.connect("ylim_changed", track_yax)


# Do the plotting:
ax.plot([0, 5, 2, 4, 1], 'o-')
ax.grid(True)

plt.show()

figure1

Matplotlib version

  • Operating system: Debian 4.13.4-2 (Sid) x86_64 GNU/Linux
  • Matplotlib version: 2.1.0.post484.dev0+g883096231 (git master)
  • Matplotlib backend: Qt5Agg
  • Python version: Python 3.6.3 on Anaconda 5.0.1

Activity

  1. tacaswell
    added this to the This milestone has been deleted milestone on Oct 29, 2017
  2. tacaswell commented on Oct 29, 2017

    @tacaswell
    tacaswell
    on Oct 29, 2017
    Member
    More actions

    I have a vauge memory of there being related issue that zoom was not going through the normal code path.

    Maybe related to #2790

  3. github-actions commented on Apr 23, 2023

    @github-actions
    github-actionsBot
    on Apr 23, 2023
    More actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  4. github-actions
    added
    status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
    on Apr 23, 2023
  5. jklymak commented on Apr 23, 2023

    @jklymak
    jklymak
    on Apr 23, 2023
    Member
    More actions

    https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.secondary_yaxis.html is meant for this situation. I'm going to close this, despite the original codepath being problematic.

  6. jklymak
    closed this as not plannedon Apr 23, 2023
  7. jklymak
    removed
    status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
    on Apr 23, 2023
  8. QuLogic
    removed this from the future releases milestone on Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.