AaronS February 2016

Adding multiple tables to plotly plot

Im trying my best to figure out a way of plotting two tables on the same plotly subplots but cant seem to get past this part. Searching has has not been fruitful.

fig = tools.make_subplots(rows = 2, cols=1, subplot_titles=('Continious 

Features','Catagorical Features'))

cont_table = FF.create_table(cont_data_matrix, index= True,index_title='Feature')
cat_table = FF.create_table(cont_data_matrix, index= True,index_title='Feature')

cont_table['figure'].extend()

fig.append_trace(cont_table, 1,1)
fig.append_trace(cont_table, 2,1)

py.plot(fig)

Answers


elsherbini February 2016

I highly recommend using the cufflinks library which ties together pandas and plotly, giving pandas dataframes the iplot() command. https://plot.ly/ipython-notebooks/cufflinks/

import cufflinks as cf
import pandas as pd

table.iplot(kind='scatter', subplots=True, shape=(2,1), filename='cufflinks_test')

So now the trick is to get the table set up. You want the data for each trace to be in different columns, and the index to correspond to the X values. pivot_table() is extremely useful for getting your data into the right shape.

If you include some dummy data for cont_table and cat_table I could provide code to combine them so that the above code works.

Post Status

Asked in February 2016
Viewed 1,034 times
Voted 11
Answered 1 times

Search




Leave an answer