# ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the *cax* argument or pass *ax* or *axes* to the colorbar() method.

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

## Root Cause

Calling plt.colorbar() with no current image/mappable or after clearing the axes, so matplotlib has no parent axes to attach the colorbar to.

## Version Compatibility

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

## Workarounds

1. **** (96% success)
   ```
   im = ax.imshow(data)
fig.colorbar(im, ax=ax)
   ```
2. **** (93% success)
   ```
   fig, (ax, cax) = plt.subplots(1, 2, gridspec_kw={'width_ratios':[4,1]})
im = ax.imshow(data)
fig.colorbar(im, cax=cax)
   ```

## Dead Ends

- **** — There is no mappable yet, so the same ValueError is raised. (95% fail)
- **** — The fig keyword does not tell matplotlib which axes to steal space from. (80% fail)
