Beispiel #1
0
 def clear_plotted_items(self, graph: pg.PlotWidget):
     dataItems = graph.listDataItems()
     for i in dataItems:
         # console(i.name(), " ", y_name)
         if i is not None:
             graph.removeItem(i)
     graph.plotItem.legend.clear()
Beispiel #2
0
 def update_graph(self,
                  graph: pg.PlotWidget,
                  x,
                  y,
                  y_name,
                  x_Unit,
                  y_Unit='V',
                  color=(255, 255, 102)):
     """
     Updates a graph
     :param graph: plotWidget
     :param x: x dataset
     :param y: y dataset
     :param y_name: name (MUST)
     :param color: default: 255, 255, 102
     :return:
     """
     sizex = len(x)
     sizey = len(y)
     np_x = np.asarray(x)
     np_y = np.asarray(y)
     if sizex == sizey:
         dataItems = graph.listDataItems()
         for i in dataItems:
             # console(i.name(), " ", y_name)
             if i is not None:
                 if i.name() == y_name:
                     graph.removeItem(i)
         cpen = mkPen(color=color, width=3)
         # npx, npy = get_mod_array(np_x, np_y, self.ui.corZeroBox.isChecked(), self.ui.formulaEdit.text())
         graph.plot(np_x, np_y, pen=cpen, name=y_name)
         self.replot_saved_graphs()
         graph.setLabel('bottom', "Time scale", units=str(x_Unit))
         graph.setLabel('left', "CH scale", units=str(y_Unit))
     else:
         console("Inequality", y_name, " ; ", sizex, " ; ", sizey)
         self.append_html_paragraph(
             "Inequality: " + str(y_name) + " ; " + str(sizex) + " ; " +
             str(sizey), -1, True)