Skip to content

Bug: pplt.rc.load does not work properly #333

Closed

Description

@syrte

Description

pplt.rc.load does not work properly.
I found the problem when I was playing with ~/.proplotrc. The same problem appears as in the following example.

Steps to reproduce

I save a rc file as follows

import proplot as pplt

pplt.rc['font.size'] = 10
pplt.rc['axes.labelsize'] = 'med-large'
pplt.rc.save('proplotrc', comment=True, backup=False, description=True)
pplt.rc['font.size'],pplt.rc['axes.labelsize'], pplt.rc['label.size']

It prints (10.0, 'med-large', 'med-large')

The file is indeed updated with the lines

# Changed settings
label.size:     med-large
axes.labelsize: med-large
font.size:      10.0

Then I restart the session and load the same file as follows

import proplot as pplt
pplt.rc.load('proplotrc')
pplt.rc['font.size'],pplt.rc['axes.labelsize'], pplt.rc['label.size']

It prints (10.000000000000002, 'medium', 'medium').

Proplot version

Paste the results of import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)here.
3.4.3
0.9.5.post259

Activity

  1. syrte commented on Jan 29, 2022

    @syrte
    Author

    The problem can be located to pplt.rc._load_file.

  2. syrte commented on Jan 29, 2022

    @syrte
    Author

    It seems that a lot of things get updated when rc loads the fontsize from file, which can overwrite the setting of labelsize.
    If the file stores the keys in a different order:

    font.size:      10.0
    label.size:     med-large
    axes.labelsize: med-large
    

    Then the labelsize setting is ensured to use the file value.


    I will be satisfied with the above workaround for now. If I got time, I may dig a bit more.

  3. lukelbd commented on Jan 30, 2022

    @lukelbd
    Collaborator

    Thanks for the report. Note the reason font.size also updates all those other font settings is related to #212. When fontsize is passed to ax.format() we have to re-apply the font scalings like 'medium' and 'large' now that they are derived from a different base font.size. I guess something about the order of application is messing this up.

  4. lukelbd commented on Jan 30, 2022

    @lukelbd
    Collaborator

    This is fixed by 6ea48d5. The issue was that in the proplotrc file, font.size came after label.size. The internal implementation of _load_file caused the font.size setting to overwrite your label.size with the default value.

    Now your example

    import proplot as pplt
    pplt.rc.load('proplotrc')
    pplt.rc['font.size'],pplt.rc['axes.labelsize'], pplt.rc['label.size']

    correctly prints (10.000000000000002, 'med-large', 'med-large').

  5. syrte commented on Jan 30, 2022

    @syrte
    Author

    Many thanks for the quick fix!!!

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions