# 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
                    count += 1
                else:
                    x = ax.bar(d[0].index + count * ((d[0].index[1] - d[0].index[0]) / (left_count + right_count)), d[0][col], width=width, color=d[1], **d[4])
                    self._legend.append((col, x, d[2]))
                    x.set_label(col)
                    count += 1

    def _hist(self):
        if not self._hists:
            return
        data = []
        colors = []
        y_axises = []
        stackedes = []
        kwargses = []
        for d in self._hists:
            data.append(d[0])
            colors.append(d[1])
            y_axises.append(d[2])
            stackedes.append(d[3])
            kwargses.append(d[4])
        df = data[0]
        df = df.join(data[1:])
        y_axis = 'left'
        color = colors
        ax = self._newAx(y_side=y_axis, color=color)
        df.plot(kind='hist', alpha=.5, ax=ax, color=colors, stacked=stackedes[-1], **kwargses[-1])

    def hist(self, data, color=None, y_axis='left', stacked=False, **kwargs):
        for i, col in enumerate(data):

# 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

                    count += 1
                else:
                    x = ax.bar(d[0].index + count * ((d[0].index[1] - d[0].index[0]) / (left_count + right_count)), d[0][col], width=width, color=d[1], **d[4])
                    self._legend.append((col, x, d[2]))
                    x.set_label(col)
                    count += 1

    def _hist(self):
        if not self._hists:
            return
        data = []
        colors = []
        y_axises = []
        stackedes = []
        kwargses = []
        for d in self._hists:
            data.append(d[0])
            colors.append(d[1])
            y_axises.append(d[2])
            stackedes.append(d[3])
            kwargses.append(d[4])
        df = data[0]
        df = df.join(data[1:])
        y_axis = 'left'
        color = colors
        ax = self._newAx(y_side=y_axis, color=color)
        df.plot(kind='hist', alpha=.5, ax=ax, color=colors, stacked=stackedes[-1], **kwargses[-1])

    def hist(self, data, color=None, y_axis='left', stacked=False, **kwargs):
        for i, col in enumerate(data):

            self._hists.append((data[[col]], get_color(i, col, color), y_axis, stacked, kwargs))