You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using plt.imshow(B, alpha=alphas) where B has dimensions NxMx3 and alphas NxM ignores the the alpha parameter is silently ignored and B displayed as is.
Code for reproduction
importmatplotlibasmimportmatplotlib.pyplotaspltimportnumpyasnpA=np.arange(5*5*3).reshape((5,5,3)) / (5*5*3)
plt.imshow(A)
plt.title("A")
plt.show()
B=np.zeros(5*5*3).reshape((5,3,5))
B[2:4, 2:4] =1B.shape= (5,5,3) # do some shifting so its not grayscaleplt.imshow(B)
plt.title("B")
plt.show()
alphas=np.zeros(5*5).reshape((5,5))
alphas[B[:,:,1] >0] =0.66plt.imshow(alphas)
plt.title("Alpha mask")
plt.show()
plt.imshow(A)
plt.imshow(B, alpha=alphas) # gives wrong resultplt.title("wrong result")
plt.show()
Actual outcome
Expected outcome
Additional information
Providing just a single alpha value or the alpha instead as alpha channel in B NxMx4 works.
But there is no warning to apply this fix or automatically merge it to apply the alpha channel as expected.
Operating system
linux and windows
Matplotlib Version
3.5.2 and 3.6.0
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
'3.9.7' and 3.10.6
Jupyter version
3.4.4
Installation
conda
The text was updated successfully, but these errors were encountered:
I think the fix is either to enrich the RGB to be RGBA in this case or to raise an exception if both alphas is set for non falescolor data. I can see arguments for both, but this is the worst of all options.
Bug summary
Using
plt.imshow(B, alpha=alphas)
where B has dimensions NxMx3 and alphas NxM ignores the the alpha parameter is silently ignored and B displayed as is.Code for reproduction
Actual outcome
Expected outcome
Additional information
Providing just a single alpha value or the alpha instead as alpha channel in B NxMx4 works.
But there is no warning to apply this fix or automatically merge it to apply the alpha channel as expected.
Operating system
linux and windows
Matplotlib Version
3.5.2 and 3.6.0
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
'3.9.7' and 3.10.6
Jupyter version
3.4.4
Installation
conda
The text was updated successfully, but these errors were encountered: