You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
966 B
32 lines
966 B
# 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() |