# TypeError: 'Line2D' object is not iterable

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

## Root Cause

Passing a single line object (not a list) to plt.legend() when it expects a list of handles, or using *args incorrectly.

## Version Compatibility

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

## Workarounds

1. **Pass handles as a list** (95% success)
   ```
   line, = plt.plot([1,2,3]); plt.legend([line], ['my line'])
   ```
2. **Set labels during plot and call legend without arguments** (90% success)
   ```
   plt.plot([1,2,3], label='my line'); plt.legend()
   ```

## Dead Ends

- **Wrapping the single object in a list but still getting error** — If the list contains other non-handle objects, the error may persist. (60% fail)
- **Using plt.legend() without arguments** — This works but may not show the desired legend if labels are not set. (40% fail)
