Advertisement
qberik

Untitled

Oct 30th, 2022
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. from PyQt5 import QtWidgets as qtw
  2. from PyQt5 import QtCore as qtc
  3. from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
  4. from matplotlib.figure import Figure
  5. # Импорты которые надо добавить в начало
  6.  
  7.  
  8. def draw_some(plot):
  9. fig = Figure(figsize=(5, 5))
  10. #can = FigureCanvasQTAgg(fig)
  11. #.toolbar = NavigationToolbar2QT(can, self)
  12. #layout = qtw.QVBoxLayout(self)
  13. #layout.addWidget(toolbar)
  14. #layout.addWidget(can)fig = Figure(figsize=(5, 5))
  15. fig = Figure(figsize=(5, 5))
  16. can = FigureCanvasQTAgg(fig)
  17. layout = qtw.QVBoxLayout(plot)
  18. layout.addWidget(can)
  19.  
  20. # here you can set up your figure/axis
  21. ax = can.figure.add_subplot(111)
  22.  
  23. # plot a basic line plot from x and y values.
  24. ax.cla() # clears the axis
  25.  
  26. # тут твоё гавно
  27. X, Y = (10, 20), (10, 20)
  28.  
  29. ax.plot(X, Y )
  30. ax.grid(True)
  31. can.figure.tight_layout()
  32. can.draw()
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. app = qtw.QApplication([])
  40. qt_app = qtw.QWidget()
  41. layout = qtw.QVBoxLayout(qt_app)
  42. plot = qtw.QWidget()
  43. layout.addWidget( plot )
  44. qt_app.setLayout( layout )
  45. draw_some( plot )
  46.  
  47.  
  48. qt_app.show()
  49. app.exec_()
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement