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

Improve plot_titles #37

Open
xenct opened this issue Dec 17, 2024 · 2 comments
Open

Improve plot_titles #37

xenct opened this issue Dec 17, 2024 · 2 comments
Assignees

Comments

@xenct
Copy link
Collaborator

xenct commented Dec 17, 2024

Improve the aesthetics and proportions of plotting, especially with dataset/date_range/baseline annotations. Currently, titles may overlap depending on the arrangement of subfigures. Also, when certain figure dimensions are used, the spacing between titles may not be suitable for the required text sizes (as per ACS comms guides)

Design aesthetics were focused on vertical orientations for 4-panel plots without these annotations for a particular report, so other arrangements are not necessarily ideal.

For example, there is overlapping text when a baseline is provided:

Steps for this may include:

  • modifying xy coords for titles
  • actively adjusting coords according to figure size
  • fixing coords as distance from the edge of the figure, regardless of the figure size.
@xenct xenct self-assigned this Dec 17, 2024
@stellema
Copy link
Member

stellema commented Jan 23, 2025

I ran into the overlapping text issue as well. I found it works well (at least for the single plot_acs_hazard functon) if I change the vertical alignment (va) of the ACS and baseline text to "top" and "bottom", respectively. That way the space between the lines is always fixed.
Here is an example (based on this code):

import matplotlib as plt
import numpy as np
import xarray as xr
from acs_plotting_maps import plot_acs_hazard

# Create test data
ds = xr.Dataset(coords={'lat': np.linspace(-45, -6), 'lon': np.linspace(114, 155)})
ds['v'] = np.sin(ds.lat * np.pi / 180) * np.cos(ds.lon * np.pi / 180)
ds['v'] = (ds.v - ds.v.min()) / (ds.v.max() - ds.v.min())

fig, ax = plot_acs_hazard(
    data=ds.v,
    title='y=0.11, va="bottom" (so it\nworks for multiple lines)',
    date_range='y=0.09, va="top"',
    baseline='y=0.01, va="bottom" (ACS y=-0.01, va="top")',
    cmap=plt.cm.plasma,
    ticks=np.arange(0, 1, 0.1),
    tick_labels=None,
    cbar_label='Variable [units]',
    dataset_name='Dataset name',
    outfile="test.png",
    savefig=True,
    name="ncra_regions",
    mask_not_australia=True,
    figsize=[6, 4.5],
    xlim=(114, 154),
    ylim=(-43.5, -7.5),
    contourf=False,
    contour=False,
    select_area=None,
    land_shadow=False)

Image

@xenct
Copy link
Collaborator Author

xenct commented Feb 18, 2025

Plotting that relies on plot_acs_hazard_multi now includes titles and cbars that are positioned with respect the the number of font sizes from the edge of the plot. This means that no matter how big or small the figure is, the title, subtitle, and colorbars will not overlap with each other or obscure the figure.
This works by defining the fontsizes (as per ACS guidelines) and ensuring that titles have fixed distances from the edge of the figure (instead of relative position inside the figure)

TODO: plot_acs_hazard_1plus3 is not yet adjusted like this.

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

No branches or pull requests

2 participants