def highlight_span(start=None, end=None, color='g', alpha=0.5, grapher=None): """ A quick shortcut way to highlight regions of a chart. Uses the Grapher.df.index to translate non int-position arguments to int locations. """ if start is None and end is None: raise Exception("strat and end cannot both be None") if grapher is None: fig = charting.gcf() grapher = fig.grapher index = grapher.index if index is None: raise Exception("grapher/ax has no plots on it. Can only highlight populated ax") if start is None: start = 0 if end is None: end = len(index) # convert from object/string to pos-index if not isinstance(start, int): start = index.get_loc(start) if not isinstance(end, int): end = index.get_loc(end) grapher.ax.axvspan(start, end, color=color, alpha=alpha)
def highlight_span(start=None, end=None, color='g', alpha=0.5, grapher=None): """ A quick shortcut way to highlight regions of a chart. Uses the Grapher.df.index to translate non int-position arguments to int locations. """ if start is None and end is None: raise Exception("strat and end cannot both be None") if grapher is None: fig = charting.gcf() grapher = fig.grapher index = grapher.index if index is None: raise Exception( "grapher/ax has no plots on it. Can only highlight populated ax") if start is None: start = 0 if end is None: end = len(index) # convert from object/string to pos-index if not isinstance(start, int): start = index.get_loc(start) if not isinstance(end, int): end = index.get_loc(end) grapher.ax.axvspan(start, end, color=color, alpha=alpha)
def ohlc_plot(self, width=0.3, *args, **kwargs): fig = gcf() fig.ohlc(self, width=width, *args, **kwargs) return fig
def close_figures(): plt.close('all') charting.gcf(reset=True)