Skip to content

_map_title crashes for orthographic maps with UnboundLocalError: xpt #122

@bnlawrence

Description

@bnlawrence

This actually occurs for other plot types as well.

Version: cfplot 3.4.0; python 3.12

Observed behavior:

  • Orthographic contour plot crashes when cf-plot tries to render the map title
  • If the title is removed, the plot renders successfully

Expected behavior:

  • Orthographic contour plots should render with a title
  • At minimum, _map_title should not crash if a projection-specific title anchor has not been computed

Minimal failing scenario:

  • Projection: ortho
  • Default GUI-style settings:
    • [lat_0 = 0.0]
    • [lon_0 = 0.0
    • Render a contour plot with a non-empty title

Probable root cause:
_map_title() appears to compute xpt, ypt only for some projections, then unconditionally uses them in the non-dims branch.

From the installed 3.4.0 source, the title-anchor coordinates are assigned for cases such as:

  • npstere
  • spstere
  • lcc

but later the code does:

else:
    halign = "center"
    plotvars.mymap.text(
        xpt,
        ypt,
        title,
        ...
    )

For ortho, xpt/ypt do not appear to be initialized before this branch is reached.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Bugs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions