In [4]:
import sys
import numpy as np
import pandas as pd
import plotly
import plotly.graph_objs as go
sys.path.append('/Users/csempek/root/repos/personal/splice/')
import splice
import splice.splice_objs as so
import plotly.offline as off
off.init_notebook_mode(connected=True)
In [5]:
np.random.seed(111)
df = pd.DataFrame({
'idx': np.arange(1000) % 100,
'num': np.random.random(1000),
'cat1': ['ABCD'[np.random.randint(0, 4)] for _ in range(1000)],
'cat2': [['male', 'female'][np.random.randint(0, 2)] for _ in range(1000)],
'cat3': [['child', 'teen', 'adult'][np.random.randint(0, 3)] for _ in range(1000)],
})
In [40]:
bar = so.GroupedBars(df=df, x='cat1', y='num',
slice_by=['cat2', 'cat3'],
idx=['cat2', 'cat3'],
hover_text=['cat1', 'cat2', 'cat3'],
marker={'line': {'color':'gray', 'width':0.5}}
)
In [41]:
off.iplot(bar.figure)
In [42]:
bar.subplots(cols=2)
off.iplot(bar.subplot_figure)
In [45]:
bar = so.StackedBars(df=df, x='cat1', y='num',
slice_by=['cat2', 'cat3'],
idx=['cat2'],
hover_text=['cat1', 'cat2', 'cat3'],
marker={'line': {'color':'gray', 'width':0.5}}
)
In [47]:
off.iplot(bar.figure)
In [46]:
bar.subplots(cols=2)
off.iplot(bar.subplot_figure)
In [ ]: