# ValueError: dpi must be a positive number, got -100

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

## Root Cause

Passing a negative or zero value for the dpi parameter in savefig() or figure creation.

## Version Compatibility

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

## Workarounds

1. **Use a positive integer for dpi** (95% success)
   ```
   plt.savefig('plot.png', dpi=300)
   ```
2. **Check the variable value before passing** (90% success)
   ```
   dpi_value = 300; if dpi_value > 0: plt.savefig('plot.png', dpi=dpi_value)
   ```

## Dead Ends

- **Using a very large positive DPI like 10000** — While it doesn't raise an error, it may cause memory issues or produce excessively large files. (50% fail)
- **Passing dpi as a string like '300'** — dpi must be a number, not a string; this raises a different TypeError. (90% fail)
