fork download
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. m = 5
  5. c = 5
  6.  
  7. # when y = x
  8. x = np.arange(-4, 4)
  9. y = np.arange(-4, 4)
  10.  
  11. plt.axvline(color='g')
  12. plt.axhline(color='g')
  13.  
  14. plt.title("Linear Plotting")
  15.  
  16. # when y = x
  17. plt.plot(x, y, color='c', marker='D', label='Y=X')
  18.  
  19. # when y = -x
  20. plt.plot(-x, y, color='k', marker='*', label='Y=-X')
  21.  
  22. # when slope = 5 and intercept = 5
  23. plt.plot(x, m * x + c, color='r', marker='o', label='Y=5x+5')
  24.  
  25. # when slope = -5 and intercept = 5
  26. plt.plot(x, -m * x + c, color='b', marker='^', label='Y=-5x+5')
  27.  
  28. plt.grid()
  29. plt.legend()
  30. plt.show()
  31.  
Success #stdin #stdout #stderr 3.5s 69832KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Fontconfig error: No writable cache directories