<jupyter_start><jupyter_text>Subplots with table and traces with different realtive  position<jupyter_code>from plotly.offline import download_plotlyjs, init_notebook_mode,  iplot, plot
init_notebook_mode(connected=True)
import pandas as pd
import datetime
df=pd.read_excel('Mining-BTC-180.xls')
df.head()
df.columns<jupyter_output><empty_output><jupyter_text>Convert each string in `df['Date']` to a datetime.date element.<jupyter_code>df['Date']=map(lambda x: x.date(),[pd.to_datetime(dr) for dr in df['Date']])
df.columns
table_trace1=dict(type = 'table',
                  domain=dict(x= [0.0, 0.5],
                             y= [0, 1.0]),
                 
                 columnwidth= [30]+[ 33, 35, 33],
                 columnorder=[0, 1, 2, 3, 4],
                 header = dict(height = 50,
                               values = [['<b>Date</b>'],['<b>Hash Rate, TH/sec</b>'], 
                                         ['<b>Mining revenue</b>'], ['<b>Transaction fees</b>']], 
                                
                               line = dict(color='rgb(50,50,50)'),
                               align = ['left']*5,
                               font = dict(color=['rgb(45,45,45)']*5, size=14),
                               fill = dict( color = '#d562be' )#fill color for header
                              ),
                 cells = dict(values = [df['Date'][-20:], df['Hash-rate'][-20:], df['Mining-revenue-USD'][-20:],
                                        df['Transaction-fees-BTC'][-20:],
                                       ],
                              line = dict(color='#506784'),
                              align = ['left']*5,
                              font = dict(color=['rgb(40,40,40)']*5, size=12),
                              format = [None]+ [",.2f"]*2+[',.4f'],  
                              prefix = [None]*2+['$', u'\u20BF'],
                              suffix=[None]*4,
                              height = 27,
                              fill = dict( color = ['rgb(235,193, 238', 'rgba(228, 222,249, 0.65)'] )
                             )
                  )

trace1=dict(type='scatter',
            x=df['Date'],
            y=df['Hash-rate'],
            xaxis='x1',
            yaxis='y1',
            mode='lines',
            line=dict(width=2, color='#9748a1'),
            name='hash-rate-TH/s')

trace2=dict(type='scatter',
            x=df['Date'],
            y=df['Mining-revenue-USD'],
            xaxis='x2',
            yaxis='y2',
            mode='lines',
            line=dict(width=2, color='#b04553'),
            name='mining revenue')

trace3=dict(type='scatter',
            x=df['Date'],
            y=df['Transaction-fees-BTC'],
            xaxis='x3',
            yaxis='y3',
            mode='lines',
            line=dict(width=2, color='#af7bbd'),
            name='transact-fee')
axis=dict(showline=True, zeroline=False, showgrid=True, mirror=True, 
          ticklen=4, gridcolor='#ffffff', tickfont=dict(size=10))
layout1 = dict(width=950, height=800, autosize=False, title='Bitcoin mining stats for 180 days',
    margin = dict(t=100,l=0,r=0,b=100),
    showlegend=False,          
    xaxis1=dict(axis, **dict(domain=[0.55,0.98], anchor= 'y1', showticklabels=False)),
    xaxis2=dict(axis, **dict(domain=[0.55,0.98], anchor= 'y2', showticklabels=False)),          
    xaxis3=dict(axis, **dict(domain=[0.55,0.98], anchor= 'y3')), 
    yaxis1=dict(axis, **dict(domain=[0.68,1], anchor= 'x1', hoverformat='.2f')),  
    yaxis2=dict(axis, **dict(domain=[0.34,0.66], anchor= 'x2', tickprefix='$', hoverformat='.2f')),
    yaxis3=dict(axis, **dict(domain=[0.0,0.32], anchor= 'x3', tickprefix=u'\u20BF', hoverformat='.2f')),          
    plot_bgcolor='rgba(228, 222,249, 0.65)' ,
    annotations=[dict(showarrow=False, 
            text='The last 20 records',  
            xref='paper',     
            yref='paper',     
            x=0.2,  
            y=1.01,  
            xanchor='left',   
            yanchor='bottom',  
            font=dict(
            size=15 ))]           
)

fig1 = dict(data=[table_trace1, trace1, trace2, trace3], layout=layout1)
iplot(fig1)
df.columns
table_trace2=dict(type = 'table',
                  domain=dict(x= [0.1, 0.9],
                             y= [0.4, 1]),
                 
                 columnwidth= [30]+[ 33, 35, 33],
                 columnorder=[0, 1, 2, 3, 4],
                 header = dict(height = 50,
                               values = [['<b>Date</b>'],['<b>Nr-transactions</b>'], 
                                         ['<b>Output-volume</b>'],
                                           ['<b>Cost-per-trans</b>']],
                               line = dict(color='rgb(50,50,50)'),
                               align = ['left']*4,
                               font = dict(color=['rgb(45,45,45)']*4, size=14),
                               fill = dict( color = '#d562be' )#fill color for header
                              ),
                 cells = dict(values = [df['Date'][-60:-44], 
                                        df['Number-transactions'][-60:-44],
                                        df['Output-volume(BTC)'][-60:-44],
                                        df['Cost-per-trans-USD'][-60:-44]
                                       ],
                              line = dict(color='#506784'),
                              align = ['left']*4,
                              font = dict(color=['rgb(40,40,40)']*4, size=12),
                              format = [None]+ ['d']+[",.2f"]*2,  
                              prefix = [None]*2+[ u'\u20BF', '$'],
                              suffix=[None]*4,
                              height = 27,
                              fill = dict( color = ['rgb(235,193, 238', 'rgba(228, 222,249, 0.65)'] )
                             )
                  )

trace4=dict(type='scatter',
            x=df['Date'],
            y=df['Number-transactions'],
            xaxis='x1',
            yaxis='y1',
            mode='lines',
            line=dict(width=2, color='#af7bbd'),
            name='nr-transac')

trace5=dict(type='scatter',
            x=df['Date'],
            y=df['Output-volume(BTC)'],
            xaxis='x2',
            yaxis='y2',
            mode='lines',
            line=dict(width=2, color='#b04553'),
            name='ouput-vol')

trace6=dict(type='scatter',
            x=df['Date'],
            y=  df['Cost-per-trans-USD'],
            xaxis='x3',
            yaxis='y3',
            mode='lines',
            line=dict(width=2, color='#9748a1'),
            name='cost-transac')
layout2 = dict(width=800, height=1000, autosize=False, title='Bitcoin transaction  summary for 180 days',
    margin = dict(t=100, l=60,r=0),
    showlegend=False,          
    xaxis1=dict(axis, **dict(domain=[0.1,0.9], anchor= 'y1', showgrid=False, showticklabels=False)),
    xaxis2=dict(axis, **dict(domain=[0.1,0.9], anchor= 'y2', showgrid=False, showticklabels=False)),
    xaxis3=dict(axis, **dict(domain=[0.1,0.9], anchor= 'y3',showgrid=False, showticklabels=True)),           
    yaxis1=dict(axis, **dict(domain=[0.28, 0.398],  anchor= 'x1', showgrid=False, hoverformat='d')), 
    yaxis2=dict(axis, **dict(domain=[0.14, 0.26],  anchor= 'x2', showgrid=False, tickprefix= u'\u20BF', hoverformat='.2f')), 
     yaxis3=dict(axis, **dict(domain=[0, 0.12],  anchor= 'x3', showgrid=False, tickprefix='S', hoverformat='.2f')),            
    plot_bgcolor='rgba(228, 222,249, 0.65)', 
    annotations=[dict(showarrow=False, 
            text='16 records around the date of september 3, 2017',  
            xref='paper',     
            yref='paper',     
            x=0.2,  
            y=1.01,  
            xanchor='left',   
            yanchor='bottom',  
            font=dict(
            size=15 ))], 
                
    shapes=[dict(type='rect',
                 xref='x3',
                 yref='y3',
            x0=df['Date'].iloc[-60],
            y0=8,
            x1=df['Date'].iloc[-43],
            y1=53,
            layer='below',
            line=dict(color='rgba(235,193, 238, 0.9)', width=0.5),
            fillcolor= 'rgba(235,193, 238, 0.9)'
            ),
           dict(type='rect',
                 xref='x2',
                 yref='y2',
            x0=df['Date'].iloc[-60],
            y0=3327226,
            x1=df['Date'].iloc[-43],
            y1=11801113,
            layer='below',
            line=dict(color='rgba(235,193, 238, 0.9)', width=0.5),
            fillcolor= 'rgba(235,193, 238, 0.9)'
            ),
           dict(type='rect',
                 xref='x1',
                 yref='y1',
            x0=df['Date'].iloc[-60],
            y0=130875,
            x1=df['Date'].iloc[-43],
            y1=375098,
            layer='below',
            line=dict(color='rgba(235,193, 238, 1)', width=0.5),
            fillcolor= 'rgba(235,193, 238, 1)'
            )]         
)

fig2 = dict(data=[table_trace2, trace4, trace5, trace6], layout=layout2)
iplot(fig2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1754945054945055, 'fraction_numerical': 0.06285714285714286, 'mean_word_length': 1.4941079747876131, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '19007', 'license': 'CC-BY-3.0', 'n_tokens_mistral': 3177, 'n_tokens_neox': 2871, 'n_words': 446, 'path': '_posts/python-v3/basic/table-subplots/Subplots-with-table-Plotly/Subplots-with-table-Plotly.ipynb', 'repo_name': 'arauzo/graphing-library-docs', 'size': '9100'}