Replace with

```python
f, ax = plt.subplots()
```

and remove figure creation on line 28