以下问题解释如何更改图例的背景颜色:
matplotlib legend background color。但是,如果我使用seaborn,则此方法不起作用。有没有办法做到这一点?
import matplotlib.pyplot as plt
import numpy as np
a = np.random.rand(10,1)
plt.plot(a, label='label')
legend = plt.legend()
frame = legend.get_frame()
frame.set_facecolor('green')
plt.show()
import seaborn as sns
plt.plot(a, label='label')
legend = plt.legend()
frame = legend.get_frame()
frame.set_facecolor('green')
plt.show()
add_legend
方法:https://github.com/mwaskom/seaborn/blob/master/seaborn/axisgrid.py - xecafeseaborn.axisgrid.Grid
,而且轴上也没有add_legend
方法。 - mathause