from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

from .geom import geom
from ggplot.components import smoothers

import numpy as np

class geom_smooth(geom):
    DEFAULT_AES = {'alpha': 0.4, 'color': 'black', 'fill': '#999999',
                   'linetype': 'solid', 'size': 1.0,
                   'ymin': None, 'ymax': None}
    REQUIRED_AES = {'x', 'y'}
    DEFAULT_PARAMS = {'stat': 'smooth', 'position': 'identity'}

    _aes_renames = {'linetype': 'linestyle', 'fill': 'facecolor',
                    'size': 'linewidth', 'ymin': 'y1', 'ymax': 'y2'}
    _units = {'color', 'facecolor', 'linestyle', 'linewidth'}

    def _plot_unit(self, pinfo, ax):
        x = pinfo.pop('x')
        y = pinfo.pop('y')

        # Remove parameters not needed for the
        # line/curve plot
        y1 = pinfo.pop('y1')
        y2 = pinfo.pop('y2')
        facecolor = pinfo.pop('facecolor')
        alpha = pinfo.pop('alpha')

        ax.plot(x, y, **pinfo)

        # If the fill limits have been computed,
        # then filling is required
        if (y1 is not None) and (y2 is not None):
            del pinfo['color']
            del pinfo['linewidth']
            pinfo['facecolor'] = facecolor
            pinfo['alpha'] = alpha
            ax.fill_between(x, y1, y2, **pinfo)

@@ -112,85 +112,123 @@
 rom 
-.geom import geom%0Afrom ggplot.components import smoothers%0A%0Aimport numpy as np
+copy import deepcopy%0A%0Afrom .geom import geom%0Afrom .geom_ribbon import geom_ribbon%0Afrom .geom_line import geom_line%0A
 %0A%0Acl
@@ -606,27 +606,69 @@
    '
-size': 'linewidth',
+color': 'edgecolor', 'size': 'linewidth',%0A                   
  'ym
@@ -707,16 +707,29 @@
 its = %7B'
+alpha', 'edge
 color', 
@@ -776,471 +776,201 @@
     
-def _plot_unit(self, pinfo, ax):%0A        x = pinfo.pop('x')%0A        y = pinfo.pop('y')%0A%0A        # Remove parameters not needed for the%0A        # line/curve plot%0A        y1
+@staticmethod%0A    def draw(pinfo, scales, ax, **kwargs):%0A        has_ribbon
  = 
+(
 pinfo
-.pop('y1')%0A        y2 = pinfo.pop('y2')%0A        facecolor = pinfo.pop('facecolor')%0A        alpha = pinfo.pop('alpha')%0A%0A        ax.plot(x, y, **pinfo)%0A%0A        # If the fill limits have been computed,%0A        # then filling is required%0A        if (y1 is not None) and (y2 is not None):
+%5B'y1'%5D is not None) and (pinfo%5B'y2'%5D is not None)%0A        if has_ribbon:%0A            pinfo2 = deepcopy(pinfo)
 %0A   
@@ -982,26 +982,32 @@
     
-del 
 pinfo
+2
 %5B'
+edge
 color'%5D
+ = ''
 %0A   
@@ -1019,78 +1019,56 @@
     
-del pinfo%5B'linewidth'%5D%0A            pinfo%5B'facecolor'%5D = facecolor%0A    
+geom_ribbon.draw(pinfo2, scales, ax, **kwargs)%0A%0A
     
@@ -1088,21 +1088,17 @@
 pha'%5D = 
-alpha
+1
 %0A       
@@ -1102,44 +1102,48 @@
     
-    ax.fill_between(x, y1, y2, **pinfo
+geom_line.draw(pinfo, scales, ax, **kwargs
 )%0A

Update geom_smooth