我已经使用seaborn构建了一个小提琴图,我想将其另存为图像。该图是在控制台中这样打印的:
但它会随裁剪的图例一起保存:
有人知道我该如何解决吗? 代码:
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")