{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plotly shapes\n", "\n", "

" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import plotly.plotly as py" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ihateyouloveme67 = py.get_figure('https://plot.ly/~ihateyouloveme/67/ch-on-ch-off-ch-flow/')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ihateyouloveme67['layout'] = {}\n", "ihateyouloveme67['layout']['shapes'] = [{}]\n", "ihateyouloveme67['layout']['annotations'] = [{}]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ihateyouloveme67['layout']['shapes'][0] = {\n", " 'fillcolor': u'#d3d3d3',\n", " 'opacity': 0.2,\n", " 'type': u'rect',\n", " 'x0': '2015-03-24 08:00:00',\n", " 'x1': '2015-03-24 10:00:00',\n", " 'xref': u'x',\n", " 'y0': 0,\n", " 'y1': 1,\n", " 'yref': u'paper' \n", "}\n", "\n", "ihateyouloveme67['layout']['annotations'][0] = {\n", " 'showarrow': False,\n", " 'text': 'IMPORTANT',\n", " 'xref': 'x',\n", " 'x': '2015-03-24 09:00:00',\n", " 'yref': 'paper',\n", " 'y': 1,\n", " 'yanchor': 'bottom'\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**N.B.** Turn off validatation" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "py.iplot(\n", " ihateyouloveme67,\n", " validate=False,\n", " filename='shade-a-region-using-shapes'\n", ")" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from IPython.display import display, HTML\n", "import urllib2\n", "url = 'https://raw.githubusercontent.com/plotly/python-user-guide/master/custom.css'\n", "display(HTML(urllib2.urlopen(url).read()))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }