# FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/path/figure.png'

- **ID:** `python/matplotlib-plot-directory-error`
- **Domain:** python
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to save a figure to a directory that does not exist.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.7 | active | — | — |
| 3.8 | active | — | — |

## Workarounds

1. **Create the directory before saving** (95% success)
   ```
   import os; os.makedirs('/nonexistent/path', exist_ok=True); plt.savefig('/nonexistent/path/figure.png')
   ```
2. **Use a valid existing directory** (90% success)
   ```
   plt.savefig('./figure.png')
   ```

## Dead Ends

- **Using a relative path without checking current working directory** — If the relative path points to a non-existent directory, the error persists. (70% fail)
- **Creating the file manually before saving** — The directory must exist; creating the file alone does not create parent directories. (90% fail)
