Advertisement
kingbode

Untitled

Aug 6th, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import math
  3.  
  4. # save plot of curve to image
  5. def curveToImage(curve, filename):
  6.     plt.title(filename)
  7.     plt.xlabel('Year')
  8.     plt.ylabel('Some measurements')
  9.     plt.plot(curve)
  10.     plt.savefig(filename)
  11.     plt.show()
  12.     plt.close()
  13.     return
  14.  
  15.  
  16. def generateCurve():
  17.     # generate curve for sine wave and return the curve
  18.     curve = []
  19.     for i in range(0, 50):
  20.         curve.append(math.sin(i))
  21.     return curve
  22.  
  23.  
  24. sineWavecurve = generateCurve()
  25. curveToImage(sineWavecurve, 'curveToImageV1.0.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement