Skip to content

Passing 'fontsize' to format() has no effect on subplot font #212

Closed

Description

@miniufo

I have a plot of two panels, one with projection and one without:
image

I want to modify the tick label size of both panels. It is possible to modify the font size in panel b (no projection) using tick.labelsize in .proplotrc. But the lat/lon label size in panel a (with projection) cannot be changed accordingly.

I also wonder if there is a more convient way of changing font size in the single format() call, because ax.format(fontsize=20) seems not take any effect.

Activity

  1. changed the title [-]change the fontsize of lat/lon tick labels[/-] [+]Passing 'fontsize' to format() has no effect on subplot font[/+] on Jun 29, 2021
  2. lukelbd commented on Jun 29, 2021

    @lukelbd
    Collaborator

    Hi @miniufo, you're right that fontsize (which represents the rc['font.size'] property) should change the axes font when passed to ax.format(). It is unfortunately sometimes unclear which rc settings can be applied to axes with format(). I'll add this as a feature at some point.

    For now you have two options:

    1. Change the default fontsize with e.g. plot.rc['font.size'] = 6. Note this will have an effect on all plot elements, both titles and labels, whose sizes are specified relative to font.size with values like 'small' and 'large'.
    2. Change both the geographic plot and cartesian plot label sizes with axs.format(gridlabelsize=size, ticklabelsize=size) or e.g. plot.rc.update({'grid.labelsize': size, 'tick.labelsize': size}). "Grid labels" correspond to labels of meridian/parallel gridlines, and "tick labels" correspond to labels along cartesian plots ticks.

    See this page for more info.

  3. lukelbd commented on Jul 6, 2021

    @lukelbd
    Collaborator

    This is now fixed. The fix was relatively simple, I just have to track which rc settings can have font size-relative values like 'small' and 'large' then update them whenever rc['font.size'] is changed.

    Below is an example. Note by default, just like matplotlib, proplot uses font size-relative units for all content -- so passing fontsize=N changes the size of pretty much all text.

    import proplot as plot
    fig, ax = plot.subplots()
    ax.format(fontsize=20, xlabel='foo', ylabel='bar', title='Title', suptitle='Big title')
    fig.show()

    text

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