@ioannis, The idea I suggest is to define a subplot with two rows and one column explicitly, and insert the info to be displayed as annotations.
import numpy as np
import plotly.graph_objs as go
x=[k*6 for k in range(10)]
h1 = -1
h2 = -1.5
trace0=go.Scatter(x=x,
y= [1-k*0.05 for k in range(10)],
mode='lines',
line =dict(width=1, color='blue'),
name='',
xaxis='x',
yaxis='y')
trace1=go.Scatter(x=x+[None]+x,
y=[h1]*len(x)+[None]+[h2]*len(x),
mode ='text',
text=np.random.randint(3, 457, len(x)).tolist()+[None]+np.random.randint(6, 706, len(x)).tolist(),
hoverinfo='text',
name='',
xaxis='x2',
yaxis='y2')
annotations=[{'font': {'size': 14},
'showarrow': False,
'text': 'Title1',
'x': 0.5,
'xanchor': 'center',
'xref': 'paper',
'y': 1.0,
'yanchor': 'bottom',
'yref': 'paper'},
{'font': {'size': 14},
'showarrow': False,
'text': 'Time (months)',
'x': 0.5,
'xanchor': 'center',
'xref': 'paper',
'y': 0.22,
'yanchor': 'bottom',
'yref': 'paper'}]
#append here, to annotations, all dicts for text you want to display before setting layout['annotations']=annotations
#because after defining an instance fw of `go.FigureWidget` you cannot append any dict to #`fw.layout.annotations`.
#set axes properties:
d_axes={'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'range': [-1,55], 'tick0':0, 'dtick': 6},
'xaxis2': {'anchor': 'y2', 'domain': [0.0, 1.0], 'range':[-1,55], 'visible': False},
'yaxis': {'anchor': 'x', 'domain': [0.4, 1.0]},
'yaxis2': {'anchor': 'x2', 'domain': [0.0, 0.2], 'range': [h2-0.1, h1+0.1], 'visible':False}}
layout=go.Layout(width=700, height=450,
font=dict(size=12),
showlegend=False,
hovermode='closest',
**dict(d_axes),
annotations=annotations )
fw=go.FigureWidget(data=[trace0, trace1], layout=layout)
fw
It is recommended this explicit definition of subplots, because if you define
fig=plotly.tools.make_subplots()
you cannot perform fig.layout.annotations.append({})
.
Following the code above you have to define all annotations, first, to avoid any illegal append to fw.layout.annotations
.
All other properties of fw
can be updated, eventually via fw.batch_update()