我希望能夠在matplotlib中使用alpha複製主色('r','g'或'b')的外觀在保持阿爾法爲1的同時,保持alpha爲1.在matplotlib中計算alpha等於0.5的alpha基礎顏色在白色背景下的RGB等效
下面是一個例子,通過手動實驗,我找到了alpha值爲1的RGB值,看起來類似於matplotlib默認顏色alpha 0.5。
我想知道如果有人有一個自動化的方式來實現這一點。
import matplotlib.pyplot as plt
s=1000
plt.xlim([4,8])
plt.ylim([0,10])
red=(1,0.55,0.55)
blue=(0.55,0.55,1)
green=(0.54,0.77,0.56)
plt.scatter([5],[5],c='r',edgecolors='none',s=s,alpha=0.5,marker='s')
plt.scatter([6],[5],c='b',edgecolors='none',s=s,alpha=0.5,marker='s')
plt.scatter([7],[5],c='g',edgecolors='none',s=s,alpha=0.5,marker='s')
plt.scatter([5],[5.915],c=red,edgecolors='none',s=s,marker='s')
plt.scatter([6],[5.915],c=blue,edgecolors='none',s=s,marker='s')
plt.scatter([7],[5.915],c=green,edgecolors='none',s=s,marker='s')
這裏差不多quesion:HTTP: //jackvdflow.com/questions/2049230/convert-rgba-color-to-rgb – jakevdp
@jakevdp我不好意思發現;不過,我希望你沒有刪除你的答案; matplotlib用戶會發現你的答案有用,例如你的python函數做映射 – themachinist