import sys
import scipy as sp
import numpy as np
import pandas as pd
import plotly.plotly as py
import cufflinks as cf

# simple return sys version
def version():
    return sys.version

# common helper for plotting functions in plotly
# using cufflinks, wrapped over erlang,
# return the url holding the plot to use in the client 
def jun_dataframe_iplot(df, _filename, keywords=[]):
    if ( isinstance(df, pd.core.frame.DataFrame) ):
        # make dict from keywords even if empty!
        kwargs = dict(keywords)
        # IMPORTANT: check if columns has the x and y, otherwise remove to plot
        x = kwargs.get('x')
        y = kwargs.get('y')
        columns = list(df)
        if x not in columns:
          del kwargs['x']
        if y not in columns:
          del kwargs['y']
        # explicity execute the fun
        iplot = df.iplot(**kwargs)
        # since iplot is an object of plotly.tools.PlotlyDisplay class, then make as plot
        url = py.plot(iplot, auto_open=False) 
        return url
    else:
        return 'error_format_data_frame_invalid'

@@ -111,16 +111,128 @@
 ks as cf
+%0Afrom erlport.erlterms import Atom%0A%0A# define a global dict to store items that not working pickled%0Apickling = %7B%7D
 %0A%0A# simp
@@ -445,16 +445,22 @@
 def jun_
+iplot_
 datafram
@@ -464,28 +464,16 @@
 rame
-_iplot(df, _filename
+(df, key
 , ke
@@ -973,98 +973,277 @@
     
-# since iplot is an object of plotly.tools.PlotlyDisplay class, then make as plot%0A   
+pickling%5Bkey%5D = iplot%0A        # use get data since this should be achive as figure%0A        return (Atom(%22plotly.iplot%22), key)%0A    else:%0A        return 'error_format_data_frame_invalid'%0A%0Adef jun_iplot_plot(iplot, _filename, keywords=%5B%5D):%0A    iplot = pickling%5Biplot%5D%0A
     
- 
 url 
@@ -1279,14 +1279,9 @@
 lse)
- %0A    
+%0A
     
@@ -1295,63 +1295,246 @@
 url%0A
-    else:%0A        return 'error_format_data_frame_invalid'
+%0Adef jun_iplot_extend(iplot_x, iplot_y, keywords=%5B%5D):%0A    iplot_yy = pickling%5Biplot_y%5D%0A    iplot_xx = pickling%5Biplot_x%5D%0A    iplot_yy%5B'data'%5D.extend(iplot_xx%5B'data'%5D)%0A    pickling%5Biplot_y%5D = iplot_yy%0A    return (Atom(%22plotly.iplot%22), iplot_y)
 %0A

add functions to extend iplot interface