尝试将绘图保存到 png 文件时遇到问题。当我尝试使用 时.jpg
,一切都很好。所以,问题是图形没有与轴和轴的标题一起保存,只有内容。如何保存它以保存所有内容?
#creating a scatter plot
fig = df.plot(kind='scatter', x='sentimentscore', y='sentimentmagnitude', c = col)
plt.axvline(0, 0, 10, color = "grey") #creating vertical dividing line
plt.xlabel('Sentiment score')
plt.ylabel('Sentiment magnitude')
plt.title('Sentiment analysis')
fig.set_ylim([3, 15])
#annotating points with track numbers
for i in range(len(x)):
plt.annotate(track[i], (x[i] - 0.002, y[i] + 0.25))
fig.figure.savefig("transparentgraph1.png", transparent=True, bbox_inches='tight', dpi=200)
fig.figure.savefig("graph1.png", bbox_inches='tight', dpi=200)