Кусок из скрипта, который строит графики в реальном времени:
@app.callback(Output('live-update-graph', 'figure'),
Input('interval-component', 'n_intervals'))
def update_graph_live(n):
df=pd.read_csv('/home/gluk/forstream.csv')
ln=len(df)
if ln<500:
df1=df.tail(ln)
else:
df1=df.tail(500)
fig = plotly.tools.make_subplots(rows=2, cols=2,
shared_xaxes=True,
vertical_spacing=0.03,
horizontal_spacing = 0.02,
column_widths=[0.65, 0.35])
fig['layout']['margin'] = {
'l': 0, 'r': 0, 'b': 0, 't': 0
}
fig['layout']['legend'] = {'x': 0, 'y': 1, 'xanchor': 'left'}
fig.append_trace({
'x': df1['T'], #Время
'y': df1['HAE'],#Канал Восток
'name': 'HAE',
'mode': 'lines+markers',
'type': 'scatter'
},1,1)
fig.append_trace({
'x': df1['T'], #Время
'y': df1['HAN'], #Канал север
'text': df1['T'],
'name': 'HAN',
'mode': 'lines+markers',
'type': 'scatter'
},2,1)
fig.append_trace({ #График зависимости двух каналов
'x': df1['HAE'],
'y': df1['HAN'],
'text': df1['T'],
'name': 'HAE vs HAN',
'mode': 'markers',
'type': 'scatter',
},2,2
)
fig.update_layout(height=700,
template="plotly_white",
margin=dict(
t=10,
b=0
))
return (fig)
Задача сделать так, чтобы последний график (позиция 2,2) имел квадратную форму и занимал часть или всю позицию (1,2). Квадратная форма необходима для того, чтобы сделать один масштаб осей конкретно на этом графике. Пока не нашел как сделать такую конфигурацию subplots в plotly. Спасибо!!!