Guest User

Untitled

a guest
Nov 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. def plot(self):
  2.  
  3. import numpy as np
  4. from matplotlib import pyplot as plt
  5.  
  6. fig = plt.figure()
  7. ax = fig.add_subplot(111)
  8. # plot triangle
  9. ax.plot(np.hstack((self.v[:, 0], self.v[0, 0])),
  10. np.hstack((self.v[:, 1], self.v[0, 1])),
  11. 'k-', label='Triangle')
  12. ax.axis('equal')
  13. ax.grid(ls='--', lw=0.6)
  14. ax.legend()
  15. return ax
  16.  
  17. def plot(self):
  18.  
  19. from matplotlib import pyplot as plt
  20. import numpy as np
  21.  
  22. alpha = np.linspace(0, 2 * np.pi, 1000)
  23. self.x = self.center[0] + self.radius * np.cos(alpha)
  24. self.y = self.center[1] + self.radius * np.sin(alpha)
  25. fig = plt.figure()
  26. ax = fig.add_subplot(111)
  27. # plot circle
  28. ax.plot(self.x, self.y, 'r-', label='Circle')
  29. ax.axis('equal')
  30. ax.grid(ls='--', lw=0.6)
  31. ax.legend()
  32. return ax
  33.  
  34. def plotintrianglecircle(self):
  35.  
  36.  
  37. from matplotlib import pyplot as plt
  38.  
  39. c = Circle(self.center, self.radius)
  40. fig1 = c.plot()
  41. fig2 = self.plot()
  42. plt.plot(fig1)
  43. plt.hold(True)
  44. plt.plot(fig2)
  45.  
  46. return
Add Comment
Please, Sign In to add comment