fr0stn1k

Untitled

Jan 29th, 2021
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import matplotlib
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. import matplotlib.backends.backend_agg as agg
  5.  
  6. class Graph():
  7.  
  8. def __init__(self, x, y, z, k, a, b):
  9.  
  10. self.x = x
  11. self.y = y
  12.  
  13. fig, (ax1, ax2, ax3) = plt.subplots(
  14. nrows=1, ncols=3,
  15. figsize=(8, 4)
  16. )
  17.  
  18. ax1.plot(x, y)
  19. ax1.spines['left'].set_position('center')
  20. ax1.spines['bottom'].set_position('center')
  21. ax1.spines['top'].set_visible(False)
  22. ax1.spines['right'].set_visible(False)
  23.  
  24. ax2.plot(z, k)
  25. ax2.spines['left'].set_position('center')
  26. ax2.spines['bottom'].set_position('center')
  27. ax2.spines['top'].set_visible(False)
  28. ax2.spines['right'].set_visible(False)
  29.  
  30. ax3.plot(a, b)
  31. ax3.spines['left'].set_position('center')
  32. ax3.spines['bottom'].set_position('center')
  33. ax3.spines['top'].set_visible(False)
  34. ax3.spines['right'].set_visible(False)
  35.  
  36.  
  37.  
  38.  
  39. def draw_graph(self):
  40.  
  41.  
  42. # Добавление графика fig на холст
  43. canvas = agg.FigureCanvasAgg(self.fig)
  44.  
  45. # Отрисовка холста
  46. canvas.draw()
  47.  
  48. # Рендер
  49. renderer = canvas.get_renderer()
Advertisement
Add Comment
Please, Sign In to add comment