2

サブプロットの図を作成するために plotly tools コマンドmake_subplotsを使用した場合。行、列のインデックス スキームを介して個々の軸のプロパティを設定するにはどうすればよいですか?

Figure が作成されたら、append trace コマンドで row,col インデックスを使用して Figure にトレースを追加できます。x 軸または y 軸のラベルのような Figure レイアウトの他のプロパティを設定するための対応する方法はありますか?

このtools.print_grid()コマンドは、row、col が x、y 軸のインデックス番号にどのようにマップされるかを示す表を出力します。ただし、この情報を返すコマンドがあればいいのですが。

今できることは、内部変数にアクセスすることだけです。

_grid_ref

これは正しくないようです。

例として

import plotly.tools as tls
import plotly.plotly as py
from plotly.graph_objs import *

fig = tls.make_subplots(
    rows=3,    
    cols=2,
    shared_xaxes=False,
    shared_yaxes=False,
)

fig.append_trace(Scatter(x=[0,1,2],y=[0,2,4]), 2, 1) #row2 col1
fig.append_trace(Scatter(x=[0,1,2],y=[0,-1,-2]),3,2) #row3 col1

#update the yaxis label for row2, col1
row = 2
col = 1
idx, idy = fig._grid_ref[row-1][col-1]
i = int(idy.lstrip('y'))
fig['layout']['yaxis{}'.format(i)].update(dict(title='positive numbers'))
#update the yaxis label for row3 col1

#update the yaxis label for row2, col1
row = 3
col = 2
idx, idy = fig._grid_ref[row-1][col-1]
i = int(idy.lstrip('y'))
fig['layout']['yaxis{}'.format(i)].update(dict(title='negative numbers'))

py.iplot(fig)

の出力を視覚的に検査することに依存しない、上記を行うためのより良い方法がある場合print_grid()

前もって感謝します。

4

1 に答える 1

0

免責事項、私は Plotly で働いています。

残念ながら、現時点では、によって生成された軸を更新するtools.make_subplots方法は他にありません。

ここに github の問題を作成しました。この件に関するご意見をお待ちしております。

于 2015-05-25T14:31:39.520 に答える