How to change legend edges from round to sharp corners

Viewed 894

how can I change the edges of the frames for legends generated in matplotlib from round to having sharp corners?

1 Answers

Let's use set_boxstyle:

from seaborn import load_dataset
import matplotlib.pyplot as plt

df = load_dataset('tips')

df.head()

ax = df.plot('sex',['total_bill','tip'])
ax.legend().get_frame().set_boxstyle('Round', pad=0.2, rounding_size=2)

Output:

enter image description here

Related