2017-02-07 7 views
1

で複数のplot.lyの数字のうち、プロットを作成します。私は例えばplot.lyでは4つの数字、作ったPythonの

import plotly.plotly as py 
import plotly.graph_objs as go 

trace1 = go.Scatter(
    x=[0, 1, 2, 3, 4, 5, 6, 7, 8], 
    y=[8, 7, 6, 5, 4, 3, 2, 1, 0] 
) 
trace2 = go.Scatter(
    x=[0, 1, 2, 3, 4, 5, 6, 7, 8], 
    y=[0, 1, 2, 3, 4, 5, 6, 7, 8] 
) 
data = [trace1, trace2] 
fig1 = go.Figure(data=data, layout=layout) 
fig2 = go.Figure(data=data, layout=layout) 
fig3 = go.Figure(data=data, layout=layout) 
fig4 = go.Figure(data=data, layout=layout) 

は、今私はサブプロットを作りたい、と象限に各図を追加その:

from plotly import tools 
fig = tools.make_subplots(rows=2, cols=2) 

が、私は、任意のfig.append_fig()方法、唯一append_trace()方法が表示されません。 plot.lyのサブプロットにフィギュアをドロップする簡単な方法はありませんか?

+0

'append_trace()'の欠点は何ですか? –

+0

これは単なる作業です。私は個々にプロットを個別に作成し、それらを4つのプロットのセットに結合する方法がないことを発見しました。静止画としてエクスポートし、openCVなどでそれらに参加しようとしています。 – wordsforthewise

答えて

0

私はfig['data'] += dataが助けることができると思います。

import plotly.plotly as py 
import plotly.graph_objs as go 

x1 = [0, 1, 2, 3, 4, 5, 6, 7, 8] 
y1 = [8, 7, 6, 5, 4, 3, 2, 1, 0] 
x2 = [0, 1, 2, 3, 4, 5, 6, 7, 8] 
y2 = [0, 1, 2, 3, 4, 5, 6, 7, 8] 

data1 = [go.Scatter(x=x1, y=y1), go.Scatter(x=x2, y=y2)] 
data2 = [go.Scatter(x=x1, y=y1, xaxis='x2', yaxis='y2'), go.Scatter(x=x2, y=y2, xaxis='x2', yaxis='y2')] 
data3 = [go.Scatter(x=x1, y=y1, xaxis='x3', yaxis='y3'), go.Scatter(x=x2, y=y2, xaxis='x3', yaxis='y3')] 
data4 = [go.Scatter(x=x1, y=y1, xaxis='x4', yaxis='y4'), go.Scatter(x=x2, y=y2, xaxis='x4', yaxis='y4')] 

from plotly import tools 
fig = tools.make_subplots(rows=2, cols=2) 
fig['data'] += data1 
fig['data'] += data2 
fig['data'] += data3 
fig['data'] += data4 
py.plot(fig, filename = 'basic-line') 
関連する問題