# ValueError: No figure with number 1 exists

- **ID:** `python/matplotlib-savefig-no-fignum`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Calling plt.figure(1) or plt.savefig on a figure number that was closed (plt.close('all')) or never created.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (96% success)
   ```
   fig = plt.figure(num=1, figsize=(6,4))
ax = fig.add_subplot(111)
ax.plot([1,2,3])
fig.savefig('out.png')
   ```
2. **** (97% success)
   ```
   fig, ax = plt.subplots()
ax.plot([1,2,3])
fig.savefig('out.png')  # never rely on figure numbers
   ```

## Dead Ends

- **** — The figure genuinely does not exist; subsequent savefig calls will still fail. (85% fail)
- **** — draw() only redraws existing figures; it does not create one with a given number. (80% fail)
