Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
Bug summary
When a colorbar hasextend != 'neither'
, the triangles at the end of the colorbar always havealpha=1
, even when the rest of the colorbar has a different alpha value.
Code for reproduction
#!/usr/bin/env python3# -*- coding: utf-8 -*-importnumpyasnpimportmatplotlib.pyplotaspltimg=np.random.rand(5,10)alpha=0.5plt.subplot(1,2,1)plt.imshow(img,alpha=alpha,cmap='RdBu')plt.colorbar(extend='both',orientation='horizontal',label='Current behaviour')# Temporary fix to manually set the alpha of the extend patches# doesn't look perfect, but is an improvement over the current behaviourplt.subplot(1,2,2)plt.imshow(img,alpha=alpha,cmap='RdBu')cb=plt.colorbar(extend='both',orientation='horizontal',label='Temporary fix')forpatchincb._extend_patches:patch.set_alpha(alpha)plt.show()
Actual outcome
Expected outcome
The triangles at the end of the colorbar should have the same alpha as the colorbar (i.e. roughly like the temporary fix above)
Additional information
No response
Operating system
OS/X
Matplotlib Version
3.5.2
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
Python 3.10.4
Jupyter version
No response
Installation
conda