【数据展示】matplotlib中label框亮度设置
生活随笔
收集整理的這篇文章主要介紹了
【数据展示】matplotlib中label框亮度设置
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
簡述
在學習官方文檔的時候,對這個做了一個簡單的探究
代碼類容如下:
leg.get_frame().set_alpha(0.1)具體展現(xiàn):
import matplotlib.pyplot as plt import numpy as npax = plt.subplot(111) t1 = np.arange(0.0, 1.0, 0.01) for n in [1, 2, 3, 4]:plt.plot(t1, t1 ** n, label="n=%d" % n) leg = plt.legend(loc='best', ncol=4, mode="expand", shadow=True) leg.get_frame().set_alpha(0.5)plt.show()對比圖:
可以看出,這里的alpha有亮度的意思
代碼:
import matplotlib.pyplot as plt import numpy as np plt.figure(figsize=(6, 6.5)) for i in range(4):ax = plt.subplot(221+i)alpha = 0.98 / 4 * i + 0.01ax.set_title('%.3f' % alpha)t1 = np.arange(0.0, 1.0, 0.01)for n in [1, 2, 3, 4]:plt.plot(t1, t1 ** n, label="n=%d" % n)leg = plt.legend(loc='best', ncol=4, mode="expand", shadow=True)leg.get_frame().set_alpha(alpha)plt.savefig('1.png') plt.show()總結
以上是生活随笔為你收集整理的【数据展示】matplotlib中label框亮度设置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【数据展示】matplotlib.pyp
- 下一篇: 【数据展示】matplotlib设置画面