Advertisement
furas

Python - matplotlib flip/invert plot #2

Mar 25th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. #
  2. # see image: http://imgur.com/a/HRnch
  3. #
  4.  
  5. import matplotlib.pyplot as plt
  6.  
  7. y = list(range(10))
  8. x1 = [a**2 for a in y]
  9. x2 = [a**3 for a in y]
  10.  
  11. plt.subplot('241')
  12. plt.plot(x1, y, label='x^2')
  13. plt.plot(x2, y, label='x^3')
  14. plt.legend()
  15. plt.title('X,Y')
  16.  
  17. plt.subplot('242')
  18. plt.plot(x1, y, label='x^2')
  19. plt.plot(x2, y, label='x^3')
  20. plt.legend()
  21. plt.gca().invert_xaxis()
  22. plt.title('X,Y (invert X)')
  23.  
  24. plt.subplot('243')
  25. plt.plot(x1, y, label='x^2')
  26. plt.plot(x2, y, label='x^3')
  27. plt.legend()
  28. plt.gca().invert_yaxis()
  29. plt.title('X,Y (invert Y)')
  30.  
  31. plt.subplot('244')
  32. plt.plot(x1, y, label='x^2')
  33. plt.plot(x2, y, label='x^3')
  34. plt.legend()
  35. plt.gca().invert_xaxis()
  36. plt.gca().invert_yaxis()
  37. plt.title('X,Y (invert X and Y)')
  38.  
  39. plt.subplot('245')
  40. plt.plot(y, x1, label='x^2')
  41. plt.plot(y, x2, label='x^3')
  42. plt.legend()
  43. plt.title('Y,X')
  44.  
  45. plt.subplot('246')
  46. plt.plot(y, x1, label='x^2')
  47. plt.plot(y, x2, label='x^3')
  48. plt.legend()
  49. plt.gca().invert_xaxis()
  50. plt.title('Y,X (invert X)')
  51.  
  52. plt.subplot('247')
  53. plt.plot(y, x1, label='x^2')
  54. plt.plot(y, x2, label='x^3')
  55. plt.legend()
  56. plt.gca().invert_yaxis()
  57. plt.title('Y,X (invert Y)')
  58.  
  59. plt.subplot('248')
  60. plt.plot(y, x1, label='x^2')
  61. plt.plot(y, x2, label='x^3')
  62. plt.legend()
  63. plt.gca().invert_xaxis()
  64. plt.gca().invert_yaxis()
  65. plt.title('Y,X (invert X and Y)')
  66.  
  67. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement