Exemple #1
0
 def __init__(self, init_plot, datagen, info, rate=1, **kwargs):
     super(XYPlotClient, self).__init__(init_plot, datagen, info, rate,
                                        **kwargs)
     plot_args = arg_inflate_flat(1, init_plot.xdata, init_plot.ydata,
                                  init_plot.formats)
     self.plots = self.ax.plot(*plot_args)
     self.formats = inflate_input(init_plot.formats, init_plot.ydata)
     self.set_aspect()
     self.set_xy_ranges()
     self.set_log_scale()
     self.set_grid_lines()
     self.add_legend(self.plots, init_plot.ydata, init_plot.leg_label,
                     init_plot.leg_offset)
Exemple #2
0
 def __init__(self, init_hist, datagen, info, rate=1, **kwargs):
     super(HistClient, self).__init__(init_hist, datagen, info, rate,
                                      **kwargs)
     # pyqtgraph needs a trailing bin edge that mpl doesn't so check for that
     corrected_bins = self.correct_bins(init_hist.bins, init_hist.values)
     plot_args = arg_inflate_flat(1, corrected_bins, init_hist.values,
                                  init_hist.formats)
     self.hists = self.ax.plot(*plot_args, drawstyle=config.MPL_HISTO_STYLE)
     self.fill(corrected_bins, init_hist.values, init_hist.fills)
     self.formats = inflate_input(init_hist.formats, init_hist.values)
     self.set_aspect()
     self.set_xy_ranges()
     self.set_log_scale()
     self.set_grid_lines()
     self.add_legend(self.hists, init_hist.values, init_hist.leg_label,
                     init_hist.leg_offset)
Exemple #3
0
    def correct_bins(self, bins, values):
        """
        Checks that number of bins is correct for matplotlib. pyqtgraph needs a
        trailing bin edge that mpl doesn't so check for that and remove if
        needed.

        Takes the 'bins' numpy array (single or list of) and compares to the
        'values' numpy array (single or list of) and trims trailing entry from
        'bins' if its size is greater than that of the mathcing 'values'.

        Returns the corrected 'bins'.
        """
        if is_py_iter(bins) or is_py_iter(values):
            corrected_bins = []
            for bin, value in zip(inflate_input(bins, values), values):
                if bin.size > value.size:
                    corrected_bins.append(bin[1:])
                else:
                    corrected_bins.append(bin)
            return corrected_bins
        elif bins.size > values.size:
            return bins[1:]
        else:
            return bins
Exemple #4
0
 def add_legend(self, plots, plot_data, leg_label, leg_offset):
     if leg_label is not None:
         self.legend_labels = inflate_input(leg_label, plot_data)
         for plot, label in zip(plots, self.legend_labels):
             plot.set_label(label)
         self.legend = self.ax.legend(loc=leg_offset)