TomDecroos / matplotsoccer

Package to visualize soccer data
MIT License
121 stars 15 forks source link

UnboundLocalError: local variable 'fig' referenced before assignment #2

Open laudv opened 4 years ago

laudv commented 4 years ago
import matplotlib.pyplot as plt
import matplotsoccer
fig, ax = plt.subplots(1, 1)
matplotsoccer.field(show=False, ax=ax, figsize=10.0)

causes:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/.../lib64/python3.7/site-packages/matplotsoccer/fns.py", line 52, in field
    show=show,
  File "/home/.../lib64/python3.7/site-packages/matplotsoccer/fns.py", line 203, in _field
    h, w = fig.get_size_inches()
UnboundLocalError: local variable 'fig' referenced before assignment

Possible fix: fig = ax.get_figure() when ax is not None here