带有pandas.plot的透明图例

gis*_*s20 0 python plot transparency pandas

我检查了熊猫图的文件

pd.df.plot

但我找不到任何使图例透明的选项

我知道如何使用matplotlib

subplot.legend(loc='best', fancybox=True, framealpha=0.5)
Run Code Online (Sandbox Code Playgroud)

但我需要使用熊猫数据框图

任何的想法?

har*_*les 5

绘制熊猫图DataFrame将返回Matplotlib axis对象。将其保存到变量,然后调整图例设置:

ax = df.plot()
ax.legend(loc='best', fancybox=True, framealpha=0.5)
Run Code Online (Sandbox Code Playgroud)

例:

import pandas as pd
import matplotlib

df = pd.DataFrame({"A": [0,1]})
ax = df.plot()
ax.legend(loc='best', fancybox=True, framealpha=0.5)
ax.plot()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明