def plot(self, yidx, xidx=(0, ), a=None, ycalc=None, left=None, right=None, ymin=None, ymax=None, ytimes=None, xlabel=None, ylabel=None, legend=True, grid=False, latex=True, dpi=200, savefig=None, show=True, use_bqplot=False, **kwargs): """ Entery function for plot scripting. This function retrieves the x and y values based on the `xidx` and `yidx` inputs and then calls `plot_data()` to do the actual plotting. Note that `ytimes` and `ycalc` are applied sequentially if apply. Refer to `plot_data()` for the definition of arguments. Parameters ---------- xidx : list or int The index for the x-axis variable yidx : list or int The indices for the y-axis variables Returns ------- (fig, ax) Figure and axis handles """ if self._mode == 'memory': if isinstance(yidx, (State, Algeb)): offs = 1 if isinstance(yidx, Algeb): offs += self.dae.n if a is None: yidx = yidx.a + offs else: yidx = np.take(yidx.a, a) + offs x_value = self.get_values(xidx) y_value = self.get_values(yidx) x_header = self.get_header(xidx, formatted=latex) y_header = self.get_header(yidx, formatted=latex) ytimes = float(ytimes) if ytimes is not None else ytimes if ytimes and (ytimes != 1): y_scale_func = scale_func(ytimes) else: y_scale_func = None # apply `ytimes` first if y_scale_func: y_value = y_scale_func(y_value) # `ycalc` is a callback function for manipulating data if ycalc is not None: y_value = ycalc(y_value) if use_bqplot is True or (use_bqplot is None and is_notebook()): return self.bqplot_data(xdata=x_value, ydata=y_value, xheader=x_header, yheader=y_header, left=left, right=right, ymin=ymin, ymax=ymax, xlabel=xlabel, ylabel=ylabel, legend=legend, grid=grid, latex=latex, dpi=dpi, savefig=savefig, show=show, **kwargs) else: return self.plot_data(xdata=x_value, ydata=y_value, xheader=x_header, yheader=y_header, left=left, right=right, ymin=ymin, ymax=ymax, xlabel=xlabel, ylabel=ylabel, legend=legend, grid=grid, latex=latex, dpi=dpi, savefig=savefig, show=show, **kwargs)
def plot(self, yidx, xidx=(0, ), a=None, ycalc=None, left=None, right=None, ymin=None, ymax=None, ytimes=None, xlabel=None, ylabel=None, legend=None, grid=False, greyscale=False, latex=True, dpi=150, line_width=1.0, font_size=12, savefig=None, save_format=None, show=True, title=None, use_bqplot=False, hline1=None, hline2=None, vline1=None, vline2=None, **kwargs): """ Entery function for plot scripting. This function retrieves the x and y values based on the `xidx` and `yidx` inputs and then calls `plot_data()` to do the actual plotting. Note that `ytimes` and `ycalc` are applied sequentially if apply. Refer to `plot_data()` for the definition of arguments. Parameters ---------- xidx : list or int The index for the x-axis variable yidx : list or int The indices for the y-axis variables Returns ------- (fig, ax) Figure and axis handles """ if self._mode == 'memory': if isinstance(yidx, BaseVar): if yidx.n == 0: logger.error(f"Variable <{yidx.name}> contains no values.") return offs = 1 if isinstance(yidx, (Algeb, ExtAlgeb)): offs += self.dae.n yidx = yidx.a + offs if a is not None: yidx = np.take(yidx, a) x_value = self.get_values(xidx) y_value = self.get_values(yidx) # header: names for variables # axis labels: the texts next to axes x_header = self.get_header(xidx, formatted=latex) y_header = self.get_header(yidx, formatted=latex) ytimes = float(ytimes) if ytimes is not None else ytimes if ytimes and (ytimes != 1): y_scale_func = scale_func(ytimes) else: y_scale_func = None # apply `ytimes` first if y_scale_func: y_value = y_scale_func(y_value) # `ycalc` is a callback function for manipulating data if ycalc is not None: y_value = ycalc(y_value) if use_bqplot is True or (use_bqplot is None and is_notebook()): return self.bqplot_data(xdata=x_value, ydata=y_value, xheader=x_header, yheader=y_header, left=left, right=right, ymin=ymin, ymax=ymax, xlabel=xlabel, ylabel=ylabel, legend=legend, grid=grid, greyscale=greyscale, latex=latex, dpi=dpi, line_width=line_width, font_size=font_size, savefig=savefig, save_format=save_format, show=show, title=title, **kwargs) else: return self.plot_data(xdata=x_value, ydata=y_value, xheader=x_header, yheader=y_header, left=left, right=right, ymin=ymin, ymax=ymax, xlabel=xlabel, ylabel=ylabel, legend=legend, grid=grid, greyscale=greyscale, latex=latex, dpi=dpi, line_width=line_width, font_size=font_size, savefig=savefig, save_format=save_format, show=show, title=title, hline1=hline1, hline2=hline2, vline1=vline1, vline2=vline2, **kwargs)