def setup(): # Run this code in start() so that it runs on the correct thread. nonlocal y, x, legend_keys, xlim, ylim, ax, fig, epoch, kwargs import matplotlib.pyplot as plt with self.__setup_lock: if self.__setup_event.is_set(): return self.__setup_event.set() if fig is not None: if ax is not None: raise ValueError( "Values were given for both `fig` and `ax`. " "Only one can be used; prefer ax.") warnings.warn("The `fig` keyword arugment of LivePlot is " "deprecated and will be removed in the future. " "Instead, use the new keyword argument `ax` to " "provide specific Axes to plot on.") ax = fig.gca() if ax is None: fig, ax = plt.subplots() self.ax = ax if legend_keys is None: legend_keys = [] self.legend_keys = ['scan_id'] + legend_keys if x is not None: self.x, *others = get_obj_fields([x]) else: self.x = 'seq_num' self.y, *others = get_obj_fields([y]) self.ax.set_ylabel(y) if (self._xlabel is None): self.ax.set_xlabel(x or 'sequence #') else: self.ax.set_xlabel(self._xlabel) if xlim is not None: self.ax.set_xlim(*xlim) if ylim is not None: self.ax.set_ylim(*ylim) self.ax.margins(.1) self.kwargs = kwargs self.lines = [] self.legend = None self.legend_title = " :: ".join( [name for name in self.legend_keys]) self._epoch_offset = None # used if x == 'time' self._epoch = epoch
def setup(): # Run this code in start() so that it runs on the correct thread. nonlocal y, x, legend_keys, xlim, ylim, epoch, kwargs import matplotlib.pyplot as plt with self.__setup_lock: if self.__setup_event.is_set(): return self.__setup_event.set() if fig_factory is None: ax_factory = plt.subplots fig, ax = fig_factory() self.ax = ax if legend_keys is None: legend_keys = [] self.legend_keys = ['scan_id'] + legend_keys if x is not None: self.x, *others = get_obj_fields([x]) else: self.x = 'seq_num' self.y, *others = get_obj_fields([y]) self.ax.set_ylabel(y) self.ax.set_xlabel(x or 'sequence #') if xlim is not None: self.ax.set_xlim(*xlim) if ylim is not None: self.ax.set_ylim(*ylim) self.ax.margins(.1) self.kwargs = kwargs self.lines = [] self.legend = None self.legend_title = " :: ".join( [name for name in self.legend_keys]) self._epoch_offset = None # used if x == 'time' self._epoch = epoch