每次使用pandas在matplotlib中绘图时,为了将图例放在图中,我必须做类似的事情:
single_obj_trading_curve_instrument_toppercentile.plot().legend(loc = "center left",bbox_to_anchor = (1,0.5))
后面的部分
.legend(loc = "center left",bbox_to_anchor = (1,0.5))
过于重复......有没有办法将其设置为默认值?谢谢,
答案 0 :(得分:1)
您可以设置
import matplotlib.pyplot as plt
plt.rcParams["legend.loc"] = "center left"
但是,您仍然需要定义bbox
df.plot().legend(bbox_to_anchor = (1,0.5))