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

[Bug]: EPS savefig messed up by 'figure.autolayout' rcParam on 3.5.0 · Issue #21930 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: EPS savefig messed up by 'figure.autolayout' rcParam on 3.5.0 #21930

Closed

Description

Bug summary

Setting 'figure.autolayout' to 'True' removes most of the EPS savefig.

Code for reproduction

import matplotlib.pyplot as plt

plt.rcParams['figure.autolayout'] = 'True'

plt.plot([1, 2, 3], [1, 2, 3], 'o-')
plt.title(r'$\sum_{i=0}^{\infty} x_i$ just a test')
plt.savefig('test2.eps', format='eps')

Actual outcome

Actual image after being exported from gimp (300dpi)

This is the EPS file:
https://we.tl/t-ka6aoUGxKm

Expected outcome

Expect the image in ".eps" file like this.

This is the EPS file:
https://we.tl/t-Q7WBPMwDcy

Additional information

I found this bug by an accident while using a custom ".mplstyle" on Matplotlib 3.5.0
Seems like this rcParam ['figure.autolayout'] = 'True' destroys about 2/3 of the eps file.
plt.tightlayout() seem to not affect the result, the bug happens only with this rcParam on the latest matplotlib version.

import matplotlib.pyplot as plt

plt.plot([1, 2, 3], [1, 2, 3], 'o-')
plt.title(r'$\sum_{i=0}^{\infty} x_i$ just a test')
plt.savefig('test2.eps', format='eps')

This is the code for the expected outcome.

Operating system

Windows

Matplotlib Version

Bug present only on 3.5.0

Matplotlib Backend

Qt5Agg

Python version

Tested with 3.10 and 3.9

Jupyter version

No response

Installation

conda

Activity

  1. jklymak commented on Dec 11, 2021

    Member

    I can confirm this, but I don't understand it. If you instead do

    import matplotlib.pyplot as plt
    
    # plt.rcParams['figure.autolayout'] = 'True'
     
    plt.figure(layout='tight')
    plt.plot([1, 2, 3], [1, 2, 3], 'o-')
    plt.title(r'$\sum_{i=0}^{\infty} x_i$ just a test')
    plt.savefig('test2.eps', format='eps')

    it works fine.

    If you use the rcParam and save as PDF it works fine. So I'm not sure why the ps backend is doing something different.

  2. jklymak commented on Dec 11, 2021

    Member

    Same behaviour with plt.rcParams['figure.constrained_layout.use'] = True.

  3. alex180500 commented on Dec 13, 2021

    Author

    Still not fixed in 3.5.1

  4. jklymak commented on Dec 13, 2021

    Member

    someone will have to dig into it before it gets fixed.

  5. QuLogic commented on Dec 16, 2021

    Member
    plt.figure(layout='tight')

    I'm not sure how you got this to work, I see no appreciable difference in the file between the rcParam vs the parameter (i.e., both are broken).

  6. jklymak commented on Dec 16, 2021

    Member

    Oh good, I must have been mixing up files somehow. Glad that it is consistent between the ways to set tight_layout...

  7. alex180500 commented on Dec 16, 2021

    Author

    I've just tested it out and...

    plt.figure(layout='tight')

    gives a broken result like with the rcParam.

    But

    plt.tight_layout()

    does not. 🤔

  8. shmilee commented on Apr 3, 2022

    I've just tested it out and...

    plt.figure(layout='tight')

    gives a broken result like with the rcParam.

    But

    plt.tight_layout()

    does not. thinking

    Same here with version 3.5.1 in archlinux.
    And some lines are lost at the end of broken eps, like gsave, grestore things:

     FontName currentdict end definefont pop
     end
     %%EndProlog
     mpldict begin
     68.4 288 translate
     475.2 216 0 0 clipbox
    -gsave
    -0 0 m
    -475.2 0 l
    -475.2 216 l
    -0 216 l
    -cl
    -1.000 setgray
    -fill
    -grestore
    -
    -................ more lines
    -
    -gsave
    -
    -384.960000 50.672828 translate
    -0.000000 rotate
    -0.000000 0 m /T glyphshow
    -grestore
    
     end
     showpage
    
  9. added this to the v3.6.0 milestone on Apr 4, 2022
  10. linked a pull request that will close this issueFIX: maybe improve renderer dance #22732on Apr 4, 2022
  11. modified the milestones: v3.6.0, v3.5.2 on Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL