Skip to content
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

automatic papersize selection by ps backend is almost certainly broken #7551

Closed
anntzer opened this issue Dec 2, 2016 · 5 comments
Closed
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Dec 2, 2016

No minimal example, but the relevant chunk (backend_ps.py) is

papersize = {'letter': (8.5,11),
             'legal': (8.5,14),
             'ledger': (11,17),
             'a0': (33.11,46.81),
             'a1': (23.39,33.11),
             <elided>
             'a10': (1.02,1.457),
             'b0': (40.55,57.32),
             'b1': (28.66,40.55),
             <elided>
             'b10': (1.26,1.76)}

def _get_papertype(w, h):
    keys = list(six.iterkeys(papersize))
    keys.sort()
    keys.reverse()
    for key in keys:
        if key.startswith('l'): continue
        pw, ph = papersize[key]
        if (w < pw) and (h < ph): return key
    else:
        return 'a0'

Note that the sorting is by name, which means that the size is the first one among "a9, a8, ..., a2, a10, a1, b9, b8, ..., b2, b10, b1" (in that order) that is larger than the requested size -- which makes no sense.

@oscargus
Copy link
Contributor

oscargus commented Apr 7, 2022

Currently the code looks like:

for key, (pw, ph) in sorted(papersize.items(), reverse=True):
if key.startswith('l'):
continue
if w < pw and h < ph:
return key
return 'a0'

so slightly different sorting. I guess that
sorted(papersize.items(), key=lambda v: v[1]) will be better as it gives:

{'a10': (1.02, 1.46),
 'b10': (1.26, 1.76),
 'a9': (1.46, 2.05),
 'b9': (1.76, 2.51),
 'a8': (2.05, 2.91),
 'b8': (2.51, 3.58),
 'a7': (2.91, 4.13),
 'b7': (3.58, 5.04),
 'a6': (4.13, 5.83),
 'b6': (5.04, 7.16),
 'a5': (5.83, 8.27),
 'b5': (7.16, 10.11),
 'a4': (8.27, 11.69),
 'letter': (8.5, 11),
 'legal': (8.5, 14),
 'b4': (10.11, 14.33),
 'ledger': (11, 17),
 'a3': (11.69, 16.54),
 'b3': (14.33, 20.27),
 'a2': (16.54, 23.39),
 'b2': (20.27, 28.66),
 'a1': (23.39, 33.11),
 'b1': (28.66, 40.55),
 'a0': (33.11, 46.81),
 'b0': (40.55, 57.32)}

@github-actions
Copy link

github-actions bot commented Apr 8, 2023

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!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 8, 2023
@oscargus
Copy link
Contributor

oscargus commented Apr 8, 2023

Based on the discussions in #22796 this is very hard to fix in a back compatible way. (But easy to fix as such.)

There were some discussions if we actually require ps, as most people probably use eps anyway. One solution is to introduce a pending deprecation for ps and see the reactions?

@anntzer
Copy link
Contributor Author

anntzer commented Apr 8, 2023

My preference would be to completely deprecate and then drop papersize, and make ps output at the size of the figure, like all other backends. We could (if there's really demand for it) additionally support figsize="a4" (and similar), auto-translating these to the corresponding inches sizes (this would not be equivalent to papersize, as the axes would default to spanning the entire papersize minus the paddings).

@github-actions github-actions bot removed the status: inactive Marked by the “Stale” Github Action label Apr 9, 2023
@tacaswell tacaswell added this to the v3.8.0 milestone Apr 27, 2023
@tacaswell
Copy link
Member

Talked about this on the call, the consensus was to remove the "auto" feature.

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.

3 participants