FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: ax.plot(x,y) disappears after changing y_scale · Issue #25124 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: ax.plot(x,y) disappears after changing y_scale #25124

Closed

Description

Bug summary

The output of ax.plot(x,y) disappears while changing y_scale from 'log' (initial scale for the y axis) to 'linear'.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

samples = np.random.normal(size = 1000)
x = np.linspace(-5,5,1000)
fig, ax = plt.subplots()
ax.hist(samples, log = True, density = True)
ax.plot(x, np.exp(-x**2/2)/np.sqrt(2*np.pi))
fig.savefig('log.pdf')
ax.set_yscale('linear')
fig.savefig('lin.pdf')

Actual outcome

lin.pdf
log.pdf

Expected outcome

lin.pdf
log.pdf

Additional information

The expected outcome is generated with matplotlib==3.5.3
fill_between and hist are working fine.

Operating system

MacOSX

Matplotlib Version

3.6.3

Matplotlib Backend

MacOSX

Python version

3.9.13

Jupyter version

No response

Installation

pip

Activity

  1. tacaswell commented on Feb 1, 2023

    Member

    I can confirm that this is a regression between 3.6.2 and 3.6.3, is still present in 3.7.0rc1 and is not a pdf related problem.

    Slightly modified reproduction script:

    import numpy as np
    import matplotlib
    import matplotlib.pyplot as plt
    
    samples = np.random.normal(size = 1000)
    x = np.linspace(-5,5,1000)
    fig, ax = plt.subplots()
    ax.set_title(f'{matplotlib.__version__}')
    ax.hist(samples, log = True, density = True)
    ax.plot(x, np.exp(-x**2/2)/np.sqrt(2*np.pi))
    fig.savefig('/tmp/log.pdf')
    plt.pause(1)
    ax.set_yscale('linear')
    plt.pause(1)
    fig.savefig('/tmp/lin.pdf')

    Thank you for the very clear report @sterinaldi !

  2. added this to the v3.7.0 milestone on Feb 1, 2023
  3. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Feb 1, 2023
  4. ksunden commented on Feb 1, 2023

    Member

    bisects to 8d8d3f5 (#24684)

    which is the (manual) backport of #24654

    Also interacts with #24634, which was modifying some of the same areas of code

    Cache invalidation strikes again

  5. ksunden commented on Feb 1, 2023

    Member

    Interestingly, the original PR (#24654) explicitly mentions the "fix log/linear toggle", and states that it "clearly works fine even with this removal"

  6. tacaswell commented on Feb 1, 2023

    Member

    It matters if there is a draw before the switch. Commenting out the save and the pause makes the linear one look correct.

    Further linear -> log works, but log -> linear does not...

  7. tacaswell commented on Feb 1, 2023

    Member

    ok, I have a fix for this and see how to test it, PR coming soon.

  8. added a commit that references this issue on Feb 1, 2023
    58cadad
  9. added 3 commits that reference this issue on Apr 19, 2026
    bb59e81
    602b491
    6e30afc
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

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.status: confirmed bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL