Advertisement
elena1234

How to create plot in Spyder

Jan 27th, 2022
929
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. t = np.linspace(0, 40, 1000) # start, finish, n points
  5. d_r = 2.5 * t
  6. d_s = 3 * (t-5)
  7.  
  8. plt.title('A Bank Robber Caught')
  9. plt.xlabel('time (in minutes)')
  10. plt.ylabel('distance (in km)')
  11.  
  12. fig, ax = plt.subplots()
  13. ax.set_xlim([0, 40])
  14. ax.set_ylim([0, 100])
  15. ax.plot(t, d_r, c='green')
  16. ax.plot(t, d_s, c='brown')
  17. plt.axvline(x=30, color='purple', linestyle='--')
  18. _ = plt.axhline(y=75, color='purple', linestyle='--')
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement