Esempio n. 1
0
 def updateGroupedPlot(self, group, plot, x, y):
     """
     Update the data for a single plot.
     
     The plot you want to update is defined by the group and plot
     id. Both numbers are starting at zero and simply increment when
     new groups/plots are added by the user, so the second plot within
     the first group is (group=0, plot=1).
     
     :param group: (int) Group id of the plot.
     :param plot: (int) Plot id of the plot.
     :param x: (ndarray) New x values for plotting.
     :param y: (ndarray) New y values for plotting.
     """
     line   = self.plotLineGroups[group][plot]
     points = self.plotPointGroups[group][plot]
     if len(x) != 0:
         xu, yu = unique_mean(x, y)
     else:
         xu, yu = [], []
     line.set_xdata(xu)
     line.set_ydata(yu)
     points.set_xdata(x)
     points.set_ydata(y)
     self._needRescale = True
Esempio n. 2
0
 def addGroupedPlot(self, label, x, y):
     """
     Creates a new plot within the last created plot group.
     
     Generally, this function creates two plots for a given dataset.
     The first plot is a scatter plot, showing all x and y values.
     The second plot is a line plot, averaging over y values if there
     are multiple occurrences of x values.
     
     The plot data can be updated by calling :func:`updateGroupedPlot`. 
     
     :param label: (str) Label to be displayed in the figure legend.
     :param x: (ndarray) Array or list of x values.
     :param y: (ndarray) Array or list of y values.
     :returns: (int) Plot id assigned for updating plots later on.
     """
     if not self.plotPointGroups: self.newPlotGroup()
     assert len(self.plotPointGroups[-1]) < len(self.linestyles), "maximum number of plot group elements reached"
     pointGroup = self.plotPointGroups[-1]
     lineGroup  = self.plotLineGroups[-1]
     if len(x) != 0:
         xu, yu = unique_mean(x, y)
     else:
         xu, yu = [], []
     points = matplotlib.lines.Line2D(x, y,
                                    color = self.colors[len(self.plotPointGroups)-1],
                                    marker = "o", ls = "")
     line = matplotlib.lines.Line2D(xu, yu, label = label,
                                    color = self.colors[len(self.plotLineGroups)-1],
                                    ls = self.linestyles[len(lineGroup)])
     pointGroup.append(points)
     lineGroup.append(line)
     self._needSetupLines = True
     
     return len(lineGroup) - 1