0
Plotlyで複数の図を1つの図に表示しようとしています。 各dfオブジェクトを作成せずに 'for'または他の方法で複数のチャートを配置するスマートな方法はありますか?多くのカテゴリのインタラクティブマップを表示するにはどうすればよいでしょうか?Plotlyを使用して複数の図を表示
import random
import plotly.offline as py
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
N = 500
x = np.linspace(0, 1, N)
y = np.random.randn(N)
z = []
foo = ['apple','amazon','facebook',
'google','ms','twitter','airbnb','tesla',
'piedpiper','hooli']
for bar in range(0,N):
z.append(random.choice(foo))
df = pd.DataFrame({'x': x, 'y': y, 'z':z})
# Hope to get feedback below
df_hooli = df.query("z=='hooli'")
df_pp = df.query("z=='piedpiper'")
data = [
go.Scatter(
x = df_hooli['x'], # assign x as the dataframe column 'x'
y = df_hooli['y'],
name = 'hooli'),
go.Scatter(
x = df_pp['x'], # assign x as the dataframe column 'x'
y = df_pp['y'],
name = 'piedpiper')
]
layout = go.Layout(
title='scatter plot with pandas',
yaxis=dict(title='random distribution'),
xaxis=dict(title='linspace')
)
fig = go.Figure(data=data, layout=layout)
# IPython notebook
py.iplot(fig, filename='pandas/line-plot-title')