{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic support for plot.ly backend\n", "\n", "Currently, it is based on matplolib and automatic translation of this into plot.ly. Only bar, line and scatter are supported." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from physt.examples import normal_h2, normal_h1\n", "from physt.plotting import plotly\n", "import physt.plotting\n", "\n", "physt.plotting.set_default_backend(\"plotly\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import plotly.offline as po\n", "po.init_notebook_mode()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "H = normal_h1()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": true }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "marker": { "color": "#1F77B4", "line": { "width": 0.5 } }, "opacity": 1, "orientation": "v", "type": "bar", "uid": "90200d66-81b1-11e8-99a8-f83441d5a912", "x": [ -4.186525632977709, -3.3753709218686963, -2.5642162107596835, -1.7530614996506713, -0.9419067885416585, -0.13075207743264627, 0.680402633676366, 1.4915573447853787, 2.3027120558943914, 3.1138667670034037 ], "xaxis": "x", "y": [ 1, 10, 140, 740, 2014, 3142, 2538, 1139, 237, 39 ], "yaxis": "y" } ], "layout": { "autosize": false, "bargap": 0, "height": 345, "hovermode": "closest", "margin": { "b": 41, "l": 42, "pad": 0, "r": 14, "t": 26 }, "showlegend": false, "title": "normal", "titlefont": { "color": "#000000", "size": 12 }, "width": 460, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "mirror": "ticks", "nticks": 10, "range": [ -4.592102988532215, 3.51944412255791 ], "showgrid": false, "showline": true, "side": "bottom", "tickfont": { "size": 10 }, "ticks": "inside", "title": "x", "titlefont": { "color": "#000000", "size": 10 }, "type": "linear", "zeroline": false }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "mirror": "ticks", "nticks": 8, "range": [ 0, 3456.2 ], "showgrid": false, "showline": true, "side": "left", "tickfont": { "size": 10 }, "ticks": "inside", "type": "linear", "zeroline": false } } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "H.plot.bar()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "line": { "color": "rgba (255, 0, 0, 1)", "dash": "solid", "width": 5 }, "mode": "lines", "name": "_line0", "type": "scatter", "uid": "90200d67-81b1-11e8-99a8-f83441d5a912", "x": [ -4.186525632977709, -3.3753709218686963, -2.5642162107596835, -1.7530614996506713, -0.9419067885416585, -0.13075207743264627, 0.680402633676366, 1.4915573447853787, 2.3027120558943914, 3.1138667670034037 ], "xaxis": "x", "y": [ 1, 10, 140, 740, 2014, 3142, 2538, 1139, 237, 39 ], "yaxis": "y" } ], "layout": { "autosize": false, "height": 345, "hovermode": "closest", "margin": { "b": 41, "l": 36, "pad": 0, "r": 14, "t": 26 }, "showlegend": false, "title": "normal", "titlefont": { "color": "#000000", "size": 12 }, "width": 460, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "mirror": "ticks", "nticks": 10, "range": [ -4.592102988532215, 3.51944412255791 ], "showgrid": false, "showline": true, "side": "bottom", "tickfont": { "size": 10 }, "ticks": "inside", "title": "x", "titlefont": { "color": "#000000", "size": 10 }, "type": "linear", "zeroline": false }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "mirror": "ticks", "nticks": 8, "range": [ -0.045757490560675115, 3.5799915510204046 ], "showgrid": false, "showline": true, "side": "left", "tickfont": { "size": 10 }, "ticks": "inside", "type": "log", "zeroline": false } } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "H.plot.line(color=\"red\", lw=5, yscale=\"log\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "marker": { "color": [ "rgba(127,0,255,1.0)", "rgba(127,0,255,1.0)", "rgba(105,34,254,1.0)", "rgba(7,171,237,1.0)", "rgba(200,229,135,1.0)", "rgba(255,0,0,1.0)", "rgba(255,144,75,1.0)", "rgba(56,230,215,1.0)", "rgba(89,59,253,1.0)", "rgba(121,9,254,1.0)" ], "line": { "color": [ "rgba(127,0,255,1.0)", "rgba(127,0,255,1.0)", "rgba(105,34,254,1.0)", "rgba(7,171,237,1.0)", "rgba(200,229,135,1.0)", "rgba(255,0,0,1.0)", "rgba(255,144,75,1.0)", "rgba(56,230,215,1.0)", "rgba(89,59,253,1.0)", "rgba(121,9,254,1.0)" ], "width": 1 }, "size": 10, "symbol": "circle" }, "mode": "markers", "type": "scatter", "uid": "90200d68-81b1-11e8-99a8-f83441d5a912", "x": [ -4.186525632977709, -3.3753709218686963, -2.5642162107596835, -1.7530614996506713, -0.9419067885416585, -0.13075207743264627, 0.680402633676366, 1.4915573447853787, 2.3027120558943914, 3.1138667670034037 ], "xaxis": "x", "y": [ 1, 10, 140, 740, 2014, 3142, 2538, 1139, 237, 39 ], "yaxis": "y" } ], "layout": { "autosize": false, "height": 345, "hovermode": "closest", "margin": { "b": 41, "l": 42, "pad": 0, "r": 14, "t": 26 }, "showlegend": false, "title": "normal", "titlefont": { "color": "#000000", "size": 12 }, "width": 460, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "mirror": "ticks", "nticks": 10, "range": [ -4.592102988532215, 3.51944412255791 ], "showgrid": false, "showline": true, "side": "bottom", "tickfont": { "size": 10 }, "ticks": "inside", "title": "x", "titlefont": { "color": "#000000", "size": 10 }, "type": "linear", "zeroline": false }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "mirror": "ticks", "nticks": 8, "range": [ 0, 3456.2 ], "showgrid": false, "showline": true, "side": "left", "tickfont": { "size": 10 }, "ticks": "inside", "type": "linear", "zeroline": false } } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "H.plot.scatter(s=100, cmap=\"rainbow\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }