如何在情节中编辑每个子图的布局

时间:2018-09-14 10:44:58

标签: python python-3.x plot hover plotly

如何为每个子图设置布局选项?

我是这样画的:

init_notebook_mode(connected=True)
col  = 1;row  = 1

fig = tools.make_subplots(rows=17, cols=2, print_grid=False)
for product in products:
trace2 = go.Scatter(
        x = x,
        y = product_agr['product'] == product]["LIFT_AU"],
        mode = 'lines',        name = ''
        ,line =dict(shape='spline', color = ('#3498db')) )

    if col % 2 == 0:
        fig.append_trace(trace2, row, 1)
        row += 1; col += 1;
    else:
        fig.append_trace(trace2, row, 2)
        col += 1;

此处设置悬浮格式仅适用于第一个子图,以及如何将其设置为所有子图

fig['layout'].update(height=5000, width=1000, title='Lift', yaxis=dict(hoverformat = '.2f') , xaxis = dict(range=[-8, 16])  

for trace in fig['data']: 
    trace['showlegend'] = False # I believe by this loop we can somehow to fix the problem

iplot(fig, config = config) 

第一个子图上的悬停是固定的,但第二个子图上的不是吗?

enter image description here

0 个答案:

没有答案