# Path: lantern/plotting/plotobj.py
# class BasePlot(with_metaclass(ABCMeta)):
#     def __init__(self, backend):
#         pass
# 
#     @abstractmethod
#     def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
#         pass
# 
#     @abstractmethod
#     def area(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def bar(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hist(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hline(self, y, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hspan(self, yhigh, ylow, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def line(self, data, color=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def scatter(self, data, color=None, x=None, y=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def step(self, data, color=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def vline(self, x, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def vspan(self, xhigh, xlow, color=None, **kwargs):
#         pass
# 
# Path: lantern/plotting/plotutils.py
# def align_yaxis_np(axes):
#     """Align zeros of the two axes, zooming them out by same ratio"""
#     axes = np.array(axes)
#     extrema = np.array([ax.get_ylim() for ax in axes])
# 
#     # reset for divide by zero issues
#     for i in range(len(extrema)):
#         if np.isclose(extrema[i, 0], 0.0):
#             extrema[i, 0] = -1
#         if np.isclose(extrema[i, 1], 0.0):
#             extrema[i, 1] = 1
# 
#     # upper and lower limits
#     lowers = extrema[:, 0]
#     uppers = extrema[:, 1]
# 
#     # if all pos or all neg, don't scale
#     all_positive = False
#     all_negative = False
#     if lowers.min() > 0.0:
#         all_positive = True
# 
#     if uppers.max() < 0.0:
#         all_negative = True
# 
#     if all_negative or all_positive:
#         # don't scale
#         return
# 
#     # pick "most centered" axis
#     res = abs(uppers + lowers)
#     min_index = np.argmin(res)
# 
#     # scale positive or negative part
#     multiplier1 = abs(uppers[min_index] / lowers[min_index])
#     multiplier2 = abs(lowers[min_index] / uppers[min_index])
# 
#     for i in range(len(extrema)):
#         # scale positive or negative part based on which induces valid
#         if i != min_index:
#             lower_change = extrema[i, 1] * -1 * multiplier2
#             upper_change = extrema[i, 0] * -1 * multiplier1
#             if upper_change < extrema[i, 1]:
#                 extrema[i, 0] = lower_change
#             else:
#                 extrema[i, 1] = upper_change
# 
#         # bump by 10% for a margin
#         extrema[i, 0] *= 1.1
#         extrema[i, 1] *= 1.1
# 
#     # set axes limits
#     [axes[i].set_ylim(*extrema[i]) for i in range(len(extrema))]
# 
# def get_color(i, col, color):
#     if isinstance(color, list):
#         c = (color[i:i + 1] or [_r()])[0]
#     elif isinstance(color, dict):
#         c = color.get(col, _r())
#     elif isinstance(color, str) and color:
#         c = color
#     else:
#         c = _r()
#     return c
# 
# Path: lantern/utils.py
# def in_ipynb():
#     ip = get_ipython()
#     if ip:
#         cfg = ip.config
#         if cfg.get('IPKernelApp', False):
#             return True
#         return False
#     return False


import matplotlib.pyplot as plt
from .plotobj import BasePlot
from .plotutils import align_yaxis_np, get_color
from ..utils import in_ipynb
                from IPython import get_ipython
        ax.autoscale(True)
        self._axes.append(ax)
        return ax

    def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
        # require all data to be present before plotting
        self._bar()
        self._hist()

        lines = []
        labels = []

        to_delete = []
        for ax in self._axes:
            # no top spines if no right
            if len(self._axes_by_side['right']) == 0:
                ax.spines['top'].set_visible(False)
                ax.spines['right'].set_visible(False)

            if ax.has_data():
                ax.legend_ = None
                ax.relim()
                ax.autoscale_view()

            else:
                self._figure.delaxes(ax)
                to_delete.append(ax)
        for ax in to_delete:
            self._axes.remove(ax)


# Path: lantern/plotting/plotobj.py
# class BasePlot(with_metaclass(ABCMeta)):
#     def __init__(self, backend):
#         pass
# 
#     @abstractmethod
#     def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
#         pass
# 
#     @abstractmethod
#     def area(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def bar(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hist(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hline(self, y, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hspan(self, yhigh, ylow, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def line(self, data, color=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def scatter(self, data, color=None, x=None, y=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def step(self, data, color=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def vline(self, x, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def vspan(self, xhigh, xlow, color=None, **kwargs):
#         pass
# 
# Path: lantern/plotting/plotutils.py
# def align_yaxis_np(axes):
#     """Align zeros of the two axes, zooming them out by same ratio"""
#     axes = np.array(axes)
#     extrema = np.array([ax.get_ylim() for ax in axes])
# 
#     # reset for divide by zero issues
#     for i in range(len(extrema)):
#         if np.isclose(extrema[i, 0], 0.0):
#             extrema[i, 0] = -1
#         if np.isclose(extrema[i, 1], 0.0):
#             extrema[i, 1] = 1
# 
#     # upper and lower limits
#     lowers = extrema[:, 0]
#     uppers = extrema[:, 1]
# 
#     # if all pos or all neg, don't scale
#     all_positive = False
#     all_negative = False
#     if lowers.min() > 0.0:
#         all_positive = True
# 
#     if uppers.max() < 0.0:
#         all_negative = True
# 
#     if all_negative or all_positive:
#         # don't scale
#         return
# 
#     # pick "most centered" axis
#     res = abs(uppers + lowers)
#     min_index = np.argmin(res)
# 
#     # scale positive or negative part
#     multiplier1 = abs(uppers[min_index] / lowers[min_index])
#     multiplier2 = abs(lowers[min_index] / uppers[min_index])
# 
#     for i in range(len(extrema)):
#         # scale positive or negative part based on which induces valid
#         if i != min_index:
#             lower_change = extrema[i, 1] * -1 * multiplier2
#             upper_change = extrema[i, 0] * -1 * multiplier1
#             if upper_change < extrema[i, 1]:
#                 extrema[i, 0] = lower_change
#             else:
#                 extrema[i, 1] = upper_change
# 
#         # bump by 10% for a margin
#         extrema[i, 0] *= 1.1
#         extrema[i, 1] *= 1.1
# 
#     # set axes limits
#     [axes[i].set_ylim(*extrema[i]) for i in range(len(extrema))]
# 
# def get_color(i, col, color):
#     if isinstance(color, list):
#         c = (color[i:i + 1] or [_r()])[0]
#     elif isinstance(color, dict):
#         c = color.get(col, _r())
#     elif isinstance(color, str) and color:
#         c = color
#     else:
#         c = _r()
#     return c
# 
# Path: lantern/utils.py
# def in_ipynb():
#     ip = get_ipython()
#     if ip:
#         cfg = ip.config
#         if cfg.get('IPKernelApp', False):
#             return True
#         return False
#     return False


# Path: lantern/plotting/plot_matplotlib.py
import matplotlib.pyplot as plt
from .plotobj import BasePlot
from .plotutils import align_yaxis_np, get_color
from ..utils import in_ipynb
                from IPython import get_ipython

        ax.autoscale(True)
        self._axes.append(ax)
        return ax

    def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
        # require all data to be present before plotting
        self._bar()
        self._hist()

        lines = []
        labels = []

        to_delete = []
        for ax in self._axes:
            # no top spines if no right
            if len(self._axes_by_side['right']) == 0:
                ax.spines['top'].set_visible(False)
                ax.spines['right'].set_visible(False)

            if ax.has_data():
                ax.legend_ = None
                ax.relim()
                ax.autoscale_view()

            else:
                self._figure.delaxes(ax)
                to_delete.append(ax)
        for ax in to_delete:
            self._axes.remove(ax)


        align_yaxis_np(self._axes)