parent
58349a1a1f
commit
e7698940d4
@ -0,0 +1,32 @@
|
||||
# TODO Clean this up.
|
||||
|
||||
|
||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
||||
from matplotlib.figure import Figure
|
||||
|
||||
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMainWindow, QGridLayout, QLabel, QSpacerItem, QSizePolicy, QComboBox, QFileDialog
|
||||
|
||||
import random
|
||||
|
||||
class PlotCanvas(FigureCanvas):
|
||||
|
||||
def __init__(self, parent=None, width=5, height=4, dpi=100):
|
||||
fig = Figure(figsize=(width, height), dpi=dpi)
|
||||
self.axes = fig.add_subplot(111)
|
||||
|
||||
FigureCanvas.__init__(self, fig)
|
||||
self.setParent(parent)
|
||||
|
||||
FigureCanvas.setSizePolicy(self,
|
||||
QSizePolicy.Expanding,
|
||||
QSizePolicy.Expanding)
|
||||
FigureCanvas.updateGeometry(self)
|
||||
self.plot()
|
||||
|
||||
|
||||
def plot(self):
|
||||
data = [random.random() for i in range(25)]
|
||||
ax = self.figure.add_subplot(111)
|
||||
ax.plot(data, 'r-')
|
||||
ax.set_title('PyQt Matplotlib Example')
|
||||
self.draw()
|
Loading…
Reference in new issue