fr0stn1k

Untitled

Jan 29th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 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. self.z = z
  13. self.k = k
  14. self.a = a
  15. self.b = b
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. def draw_graph(self):
  24.  
  25. self.figure = fig, (ax1, ax2, ax3) = plt.subplots(
  26. nrows=1, ncols=3,
  27. figsize=(8, 4)
  28. )
  29.  
  30. ax1.plot(self.x, self.y)
  31. ax1.spines['left'].set_position('center')
  32. ax1.spines['bottom'].set_position('center')
  33. ax1.spines['top'].set_visible(False)
  34. ax1.spines['right'].set_visible(False)
  35.  
  36. ax2.plot(self.z, self.k)
  37. ax2.spines['left'].set_position('center')
  38. ax2.spines['bottom'].set_position('center')
  39. ax2.spines['top'].set_visible(False)
  40. ax2.spines['right'].set_visible(False)
  41.  
  42. ax3.plot(self.a, self.b)
  43. ax3.spines['left'].set_position('center')
  44. ax3.spines['bottom'].set_position('center')
  45. ax3.spines['top'].set_visible(False)
  46. ax3.spines['right'].set_visible(False)
  47.  
  48. # Добавление графика fig на холст
  49. canvas = agg.FigureCanvasAgg(fig)
  50.  
  51. # Отрисовка холста
  52. canvas.draw()
  53.  
  54. # Рендер
  55. renderer = canvas.get_renderer()
  56.  
Advertisement
Add Comment
Please, Sign In to add comment