Example #1
0
        normalized_targetY = y[startPos:startPos + len(queryY)]
        normalized_targetY = normalized_targetY / np.sqrt(np.sum(normalized_targetY ** 2))
        self._normal_ax.plot(np.linspace(0, len(queryY), len(queryY)), normalized_targetY, "-")
        normalized_queryY = queryY / np.sqrt(np.sum(queryY ** 2))
        self._normal_ax.plot(np.linspace(0, len(queryY), len(queryY)),
                             normalized_queryY, "-")
        self._normal_ax.spines['right'].set_color('none')
        self._normal_ax.spines['top'].set_color('none')
        self._normal_ax.axis('off')
        self._normal_ax.set_autoscale_on(True)

if __name__ == "__main__":
    qapp = QtWidgets.QApplication(sys.argv)
    matchHeatGraph = PyQt5.QtWidgets.QGraphicsView()
    matchHeatGraph.setGeometry(QtCore.QRect(0, 0, 351, 351))
    # matchHeatGraph.setWidgetResizable(True)
    matchHeatGraph.setObjectName("matchHeatGraph")
    # layout = QtWidgets.QVBoxLayout(matchHeatGraph)
    #
    # graph = EmbedGraph(matchHeatGraph)
    # graph.addData(np.tan(np.linspace(0, 600, 600)))
    layout = QtWidgets.QVBoxLayout(matchHeatGraph)
    static_canvas = FigureCanvas(Figure())
    static_canvas.figure.subplots_adjust(left=0, right=1, top=1, bottom=0)
    layout.addWidget(static_canvas)
    axis = static_canvas.figure.subplots()
    x = np.linspace(0, 600, 600)
    y = np.tan(x)
    z = np.sin(np.linspace(0, 150, 150))
    axis.plot(x, y, "-")
Example #2
0
    def __init__(self,
                 windowTitle='Window',
                 x=0,
                 y=0,
                 legend=True,
                 parent=None):
        super(Window, self).__init__(parent)

        # set UI style -- options: u'Windows', u'Motif', u'CDE', u'Plastique', u'Cleanlooks', u'Macintosh (aqua)'
        # QtGui.QApplication.setStyle(QtGui.QStyleFactory.create(u'Plastique'))

        # layout
        self.setAutoFillBackground(True)
        self.centralwidget = QtGui.QWidget(self)
        self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setMargin(0)
        self.setCentralWidget(self.centralwidget)
        self.setBackgroundColor(QtCore.Qt.white)

        # create menu bar
        self.menubar = QtGui.QMenuBar(self)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 340, 22))

        # create menus
        self.menuFile = QtGui.QMenu(self.menubar)
        self.menuFile.setTitle("File")
        self.menuConfigurePlot = QtGui.QMenu(self.menubar)
        self.menuConfigurePlot.setTitle("Configure Plot")

        # create actions
        self.actionSaveAs = QtGui.QAction(self)
        self.actionSaveAs.setText("Save As...")
        self.actionConfigureSubplots = QtGui.QAction(self)
        self.actionConfigureSubplots.setText('Configure Subplots')
        self.actionConfigureAxis = QtGui.QAction(self)
        self.actionConfigureAxis.setText('Configure Axis and Curve')

        # add actions to menu
        self.menuFile.addAction(self.actionSaveAs)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menuConfigurePlot.addAction(self.actionConfigureSubplots)
        self.menuConfigurePlot.addAction(self.actionConfigureAxis)
        self.menubar.addAction(self.menuConfigurePlot.menuAction())

        # enable menu bar
        self.setMenuBar(self.menubar)

        QtCore.QMetaObject.connectSlotsByName(self)

        # get arguments
        self.windowTitle = windowTitle

        # moves menu bar into application -- mac only windows sux
        self.menubar.setNativeMenuBar(False)

        # set window title
        self.setWindowTitle(self.windowTitle)

        self.initCanvas()

        self.toolbar = CustomToolbar(self.canvas, self)
        self.verticalLayout.addWidget(self.toolbar)

        self.setWindowPosition(x, y)

        # bind file menu actions
        self.connect(self.actionSaveAs, QtCore.SIGNAL('triggered()'),
                     self.toolbar.save_figure)

        # bind configure menu actions
        self.connect(self.actionConfigureSubplots,
                     QtCore.SIGNAL('triggered()'),
                     self.toolbar.configure_subplots)
        self.connect(self.actionConfigureAxis, QtCore.SIGNAL('triggered()'),
                     self.toolbar.edit_parameters)

        if legend:
            self.generateLegendMenu()

        # create instance of Plotter class
        self.plotter = plotter.Plotter()