I've built a violinplot using seaborn and I want to save it as an image. The figure is printed in the console like this:
But it gets saved with a cropped legend:
Does anyone know how could I fix that? The code:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set('paper', color_codes=True)
protein_name = input('What is the name of your protein?')
my_pal = {"3mer": "red", "9mer": "blue"} fig =
sns.violinplot(y= 'Percentage', x= 'Secondary structure',hue= 'Type of library', data = df, split = True, palette = my_pal)
fig.set_title('Distribution of secondary structures in' + protein_name)
leg=plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.5)
leg.set_title('Type of library')
plt.ylim(0, 100)
plt.savefig(protein_name + "_violin_plots.jpg")