0

I am trying to paste my plot into my excel sheet, but it keeps popping up blank. This is super weird because the names match up, and the correct plot comes up in Spyder. If anyone could help me out that would be awesome. Here is a condensed version of my code:

plt.plot(cycle_percent, vlwf, color='blue', label='Vertical Load')
plt.title('Vertical Load Waveform')
plt.xlabel('% Cycle')
plt.ylabel('N')
plt.plot(cycle_percent, iso_max, color='red', label='ISO Max')
plt.plot(cycle_percent,iso_min, color='red', label='ISO Min')
plt.legend()
plt.show()

plt.savefig('VLWf Plot.png', dpi=150)

writer = pd.ExcelWriter('C:\\Users\\batesz\\Desktop\\python_plot.xlsx', engine = 'xlsxwriter')
plot_data.to_excel(writer, sheet_name='PS Plots')  

worksheet = writer.sheets['PS Plots']
worksheet.insert_image('C2','VLWf Plot.png')
writer.save()

I have tried using openpyxl, but I saw this code on this site and thought it may be better since I can paste png's, and wouldn't have to change the file type.

Abhi
  • 1,080
  • 1
  • 7
  • 21
Zane B
  • 1
  • 2
  • there are several undefined variables and a missing import - the question needs sufficient code for a minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example – D.L Nov 02 '22 at 20:43
  • Delete `plt.show()` before `plt.savefig('VLWf Plot.png', dpi=150)` and your plot should save properly – jylls Nov 03 '22 at 20:31

0 Answers0