import plotly.plotly as py
ihateyouloveme67 = py.get_figure('https://plot.ly/~ihateyouloveme/67/ch-on-ch-off-ch-flow/')
ihateyouloveme67['layout'] = {}
ihateyouloveme67['layout']['shapes'] = [{}]
ihateyouloveme67['layout']['annotations'] = [{}]
ihateyouloveme67['layout']['shapes'][0] = {
'fillcolor': u'#d3d3d3',
'opacity': 0.2,
'type': u'rect',
'x0': '2015-03-24 08:00:00',
'x1': '2015-03-24 10:00:00',
'xref': u'x',
'y0': 0,
'y1': 1,
'yref': u'paper'
}
ihateyouloveme67['layout']['annotations'][0] = {
'showarrow': False,
'text': 'IMPORTANT',
'xref': 'x',
'x': '2015-03-24 09:00:00',
'yref': 'paper',
'y': 1,
'yanchor': 'bottom'
}
N.B. Turn off validatation
py.iplot(
ihateyouloveme67,
validate=False,
filename='shade-a-region-using-shapes'
)
from IPython.display import display, HTML
import urllib2
url = 'https://raw.githubusercontent.com/plotly/python-user-guide/master/custom.css'
display(HTML(urllib2.urlopen(url).read()))