コード例 #1
0
ファイル: Inspect_ui.py プロジェクト: kny5/strucpy
 def createGraph(self, data, graph):
     plot = PlotItem()
     line = PlotCurveItem(x=asarray(
         [x for x in range(0, self.element.sections + 1)]),
                          y=data,
                          pxMode=True,
                          symbolSize=5)
     plot.addItem(line)
     graph.addItem(plot, row=0, col=0)
コード例 #2
0
 def __init__(self, info: pylsl.StreamInfo, plt: pg.PlotItem):
     super().__init__(info)
     # calculate the size for our buffer, i.e. two times the displayed data
     bufsize = (2 * math.ceil(info.nominal_srate() * plot_duration), info.channel_count())
     self.buffer = np.empty(bufsize, dtype=self.dtypes[info.channel_format()])
     empty = np.array([])
     # create one curve object for each channel/line that will handle displaying the data
     self.curves = [pg.PlotCurveItem(x=empty, y=empty, autoDownsample=True) for _ in range(self.channel_count)]
     for curve in self.curves:
         plt.addItem(curve)
コード例 #3
0
ファイル: y2axis.py プロジェクト: taurus-org/taurus_pyqtgraph
def _PlotItem_addItem(self, item, *args, **kwargs):
    """replacement for `PlotItem.addItem` that Y2Axis will use to monkey-patch
    the original one
    """
    PlotItem.addItem(self, item, *args, **kwargs)

    if hasattr(item, "setLogMode"):
        item.setLogMode(
            self.getAxis("bottom").logMode,
            self.getAxis("left").logMode)
コード例 #4
0
class NaturalPlotView(GraphicsView):
    """Creates a simple about dialog.

    The about dialog contains general information about the application and
    shows the copyright notice.
    That's why the class has no attributes or return values.

    """

    def __init__(self):
        super().__init__()

        # settings
        self.setBackground("#fff")
        self.setFrameStyle(QFrame.StyledPanel|QFrame.Sunken)
        self.setAntialiasing(True)

        # create custom view box
        view_box = ViewBox()
        view_box.setMouseEnabled(False, False)
        view_box.setLimits(xMin=0, yMin=0, minXRange=10, minYRange=100)
        view_box.setRange(xRange=(0, 400), yRange=(0, 5000))
        view_box.enableAutoRange()

        # create natural axis items
        self.x_axis = NaturalAxis("bottom")
        self.x_axis.setLabel(QApplication.translate("NaturalPlotView", "Fence length"), "m")
        self.y_axis = NaturalAxis("left")
        self.y_axis.setLabel(QApplication.translate("NaturalPlotView", "Number of plants"))

        # create fence information text
        self.fenceItem = TextItem(border=pyqtgraph.mkPen(width=2, color="#555"),
                fill=pyqtgraph.mkBrush((255, 255, 255, 200)))

        # create tube information text
        self.tubeItem = TextItem(border=pyqtgraph.mkPen(width=2, color="#555"),
                fill=pyqtgraph.mkBrush((255, 255, 255, 200)),
                anchor=(1,1))

        # create plot item with custom view box and natural axis items
        self.plotItem = PlotItem(viewBox=view_box,
                axisItems={"bottom" : self.x_axis, "left" : self.y_axis}, enableMenu=False)
        self.plotItem.setContentsMargins(5, 5, 12, 5)
        self.plotItem.hideButtons()
        self.plotItem.hide()
        self.setCentralWidget(self.plotItem)

        # connect actions
        view_box.sigResized.connect(self.updateTubeLegendPosition)

        # translate the plot item
        self.retranslateUi()

    def retranslateUi(self):
        # title label
        titleStyle = "color: #111; font-size: 15px; font-weight: bold"
        titleLabel = "<span style='{style}'>{title}</span>".format(style=titleStyle,
                title="Ergebnis: Funktion(en) der Kostengleichheit")
        self.plotItem.setTitle(titleLabel)

        # axis items
        #self.x_axis.setLabel(QApplication.translate("NaturalPlotView", "Fence length"), "m")
        #self.y_axis.setLabel(QApplication.translate("NaturalPlotView", "Number of plants"))

        # fence hint
        self.fenceItem.setHtml("<p style='margin: 0; color: #555'><b>" +
                QApplication.translate("NaturalPlotView", "Pfeil über Funktion(en):") + "</b> " +
                QApplication.translate("NaturalPlotView", "Zaun günstiger") + "</p>")

        # tube hint
        self.tubeItem.setHtml("<p style='margin: 0; color: #555'><b>" +
                QApplication.translate("NaturalPlotView", "Pfeil unter Funktion(en):") + "</b> " +
                QApplication.translate("NaturalPlotView", "Wuchshülle günstiger") + "</p>")


    def addPlotItem(self, item, *args, **kwargs):
        # first show the plot item
        if not self.plotItem.isVisible():
            self.plotItem.show()

        self.plotItem.addItem(item, *args, **kwargs)

    def removePlotItem(self, item):
        self.plotItem.removeItem(item)

    #TODO:
    def clear(self):
        self.plotItem.hide()
        self.plotItem.clear()

    def showDescription(self):
        viewBox = self.plotItem.getViewBox()

        self.fenceItem.setPos(15, 10)
        self.fenceItem.setParentItem(viewBox)

        rect = viewBox.screenGeometry()
        self.tubeItem.setPos(rect.width() - 15, rect.height() - 10)
        self.tubeItem.setParentItem(viewBox)

    def updateTubeLegendPosition(self):
        rect = self.plotItem.getViewBox().screenGeometry()
        self.tubeItem.setPos(rect.width() - 15, rect.height() - 10)

    def export(self, gfxfile):
        exporter = TestImageExporter(self.plotItem)
        exporter.parameters()["width"] = 2007.0   # 17 cm / 300 DPI

        # export the graphics to the selected file
        exporter.export(gfxfile)
コード例 #5
0
 def addItem(self, widget: pg.PlotItem):
     widget.addItem(self.left)
     widget.addItem(self.right)
     widget.addItem(self.center)
     widget.addItem(self.orientation)
     widget.addItem(self.direction)
     widget.addItem(self.target_direction)
コード例 #6
0
 def addItem(self, widget: pg.PlotItem):
     widget.addItem(self.center)
     widget.addItem(self.direction)
     widget.addItem(self.target_direction)