# ValueError: The 'loc' parameter must be a string or an integer between 0 and 10, but you provided 'center left' which is a valid string but misspelled.

- **ID:** `python/matplotlib-legend-loc-error`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The 'loc' string for legend placement is case-sensitive and must be one of the predefined strings like 'upper left', 'lower right', etc.; 'center left' is not valid (should be 'center left'? actually 'center left' is valid? Wait, this error is about misspelling: 'center left' vs 'center left'? Actually 'center left' is valid, but if user typed 'centre left' or 'center left' with extra space, it fails. Let's correct: The error occurs when user provides a string that is not in the allowed list, e.g., 'center left' is valid, but if misspelled as 'centr left', it raises ValueError.

## Version Compatibility

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

## Workarounds

1. **Use the exact valid string from documentation** (95% success)
   ```
   plt.legend(loc='upper left')  # or 'lower right', 'center', etc.
   ```
2. **Use a valid numeric code (0-10) for backward compatibility** (90% success)
   ```
   plt.legend(loc=2)  # 2 corresponds to 'upper left'
   ```

## Dead Ends

- **Using a numeric code like 10 thinking it maps to 'center'** — Numeric codes are deprecated in newer versions and may not work as expected; also 'center left' is not a single numeric code. (70% fail)
- **Ignoring case sensitivity and trying 'Upper Left'** — The strings are case-sensitive; 'Upper Left' is not valid, only 'upper left' works. (80% fail)
