Advertisement
informaticage

Python plot random points

Aug 4th, 2023
1,323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. #generate random tuple
  2. import random
  3. points = [(random.randint(0, 100), random.randint(0, 100)) for x in range(0, 10)]
  4.  
  5. # plot on a graph
  6. import matplotlib.pyplot as plt
  7. x = [p[0] for p in points]
  8. y = [p[1] for p in points]
  9. plt.plot(x, y, 'ro')
  10. plt.show()
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement