plot2lines.py 419 B

123456789101112131415161718
  1. #! /usr/bin/env python3
  2. # https://pythonguides.com/python-plot-multiple-lines/
  3. # Importing packages
  4. import matplotlib.pyplot as plt
  5. # Define data values
  6. x = [7, 14, 21, 28, 35, 42, 49]
  7. y = [5, 12, 19, 21, 31, 27, 35]
  8. z = [3, 5, 11, 20, 15, 29, 31]
  9. # Plot a simple line chart
  10. plt.plot(x, y, 'g', label='Line y')
  11. # Plot another line on the same chart/graph
  12. plt.plot(x, z, 'r', label='Line z')
  13. plt.legend()
  14. plt.show()