问题
When plotting a plot using matplotlib:
- How to remove the box of the legend?
- How to change the color of the border of the legend box?
- How to remove only the border of the box of the legend?
回答1:
When plotting a plot using matplotlib:
How to remove the box of the legend?
plt.legend(frameon=False)
How to change the color of the border of the legend box?
leg = plt.legend()
leg.get_frame().set_edgecolor('b')
How to remove only the border of the box of the legend?
leg = plt.legend()
leg.get_frame().set_linewidth(0.0)
回答2:
One more related question, since it took me forever to find the answer:
How to make the legend background blank (i.e. transparent, not white):
legend = plt.legend()
legend.get_frame().set_facecolor('none')
Warning, you want 'none' (the string). None means the default color instead.
来源:https://stackoverflow.com/questions/25540259/remove-or-adapt-border-of-frame-of-legend-using-matplotlib