Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate papersize=auto in PostScript #25785

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

Merged
merged 2 commits into from
Aug 9, 2023

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Apr 28, 2023

PR Summary

This automatic selection is not very good, and it's probably better for the user to explicitly select a paper type.

Additionally, I've corrected an inconsistency in EPS, which used the paper size only if not using usetex and no distiller. In the latter cases, the paper size is ignored and the distiller is told to use -dEPSCrop instead. So this makes the former case consistent with those.

PR Checklist

Linked Issue

  • Added "closes #0000" in the PR description to link it to the original issue.

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • [n/a] New plotting related features are documented with examples.

Release Notes

  • [n/a] New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • [n/a] API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

QuLogic added 2 commits April 27, 2023 21:51
When usetex is enabled, then EPS ignores the papersize passed to
`savefig` / `rcParams`. Additionally, when distilling, if outputting
EPS, the papersize is ignored.

This makes things consistent when not using usetex and not distilling.
This automation is not very good, and just saving at the figure size is
better for EPS.

Closes matplotlib#7551
@QuLogic QuLogic added this to the v3.8.0 milestone Apr 28, 2023
papersize[papertype])

if mpl.rcParams['ps.usedistiller']:
# distillers improperly clip eps files if pagesize is too small
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems incongruous with this being in the else block of if is_eps:

If this code is specifically targeted to fix eps, then it would have to be in the if block, and if it is just wrong, perhaps it could be taken out entirely.

It also relies on the _get_papertype function which the point of removing auto is to remove that function because it is problematic in implementation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point, since as the first commit notes, the distiller ignores the paper type and asks the distiller to crop, this is probably something that could be dropped. But I guess I will have to test out a few combinations to be sure.

@oscargus
Copy link
Member

I know you discussed this yesterday, which I missed, but is the thing that "auto" selects one of the defined papersizes (in an incorrect way sometimes), but not passing anything will use a large enough paper and crop it? I sort of got that it will use letter then, which may not always be large enough?

@QuLogic
Copy link
Member Author

QuLogic commented Aug 2, 2023

I've kind of forgotten how this works a bit, so I've gone and re-read everything.

For usetex, EPS uses the figure size as paper size directly, and PS uses the passed-in/rcParam papertype (or auto selection). The figure is placed at (0, 0) (by LaTeX's \includegraphics) and cropped to (0, 0, width, height) by the distiller for EPS (which should be the size anyway.)

For non-usetex, the specified/rcParam papertype (or auto selection) is used to centre the figure and the bbox is found from that. However, if a distiller is used, the papertype is expanded if necessary. The comment claims this expansion is for EPS. However, this does not make sense as EPS output does not use the papertype, just the calculated bbox.

@tacaswell tacaswell closed this Aug 2, 2023
@tacaswell tacaswell reopened this Aug 2, 2023
@tacaswell
Copy link
Member

Plan is to:

  • deprecate "auto"
  • add adding the actual figure size as the bounding box and move the default to be "figsize" or similar to match how we do dpi in savefig.

@tacaswell tacaswell merged commit 83858f4 into matplotlib:main Aug 9, 2023
@QuLogic QuLogic deleted the ps-papersize-auto branch August 9, 2023 06:33
@anntzer
Copy link
Contributor

anntzer commented Aug 9, 2023

@tacaswell Do you want to open another issue to track the work to do on your comment above?

@QuLogic
Copy link
Member Author

QuLogic commented Aug 9, 2023

I think that's covered by #16657 but I'm also working on it right now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been 25785 I just noted...

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

Successfully merging this pull request may close these issues.

6 participants