I'm having a trouble when trying to save plot to png file. When I tried with .jpg
, everything was alright. So, the problem is that graph is not saved with axes and axes' titles, there is only the content. How to save it so everything is preserved?
#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)