Skip to content

Passing figsize argument to plt.savefig() is deprecated for matplotlib>3.6 #128

@ufuk-cakir

Description

@ufuk-cakir

Running the current version of Cell2Fire(0.2) with Python (3.11.10) and matplotlib=3.10.1 on MacOS 15.4 results in an error.

Description

Calling GlobalFireSpreadEvo() results in a TypeError:

TypeError: FigureCanvasAgg.print_png() got an unexpected keyword argument ‘figsize’

Cause

This happens because figsize is passed to plt.savefig(), but it is not a valid keyword argument there. figsize should be passed when creating the figure using plt.figure(figsize=(...)).

This was deprecated for matplotlib>3.6, see here.

Here are some examples where this happens:

plt.savefig(PathFile, dpi=200, figsize=(200, 200), bbox_inches='tight', transparent=True)

Fix

  • either fix matplotlib in requirements file to matplotlib<3.6
  • or (recommended)
# Replace these:
plt.savefig("output.png", figsize=(10, 6), dpi=300)

# With:
plt.figure(figsize=(10, 6))
...
plt.savefig("output.png", dpi=300)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions