{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n" ], "text/plain": [ "HTML{String}(\" \\n\")" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " 1.468558 seconds (3.18 M allocations: 162.595 MiB, 2.30% gc time)\n" ] } ], "source": [ "@time using SimplePlots" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 1.411413 seconds (3.53 M allocations: 172.899 MiB, 3.28% gc time)\n" ] }, { "data": { "text/html": [ "
\n", " \n" ], "text/plain": [ "HTML{String}(\"
\\n \\n\")" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function foo()\n", " scatter(\n", " rand(10), label=\"Scatter\", color=4,\n", " xlabel=\"x\", markersize=6\n", " )\n", "\n", " ylabel!(\"y\")\n", "\n", " cur_x = 10 .^ (0:0.1:1)\n", " cur_y = rand(0.25:0.05:0.75, length(cur_x))\n", "\n", " plot!(cur_x, cur_y, label=\"Plot\", color=3, title=\"Example\")\n", "\n", " hline!([1,3] ./ 4, color=2)\n", " vline!(5, linewidth=4, alpha=0.4, linestyle=:dash)\n", "\n", " plot!(xlim=(1,15))\n", "\n", " ylims!(0,1)\n", " xscale!(:log10)\n", "end\n", "\n", "@time foo()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "
\n", "
\n", "
\n", " y\n", "
\n", "
\n", " 5\n", "
\n", "\n", "
\n", "
\n", "
\n", " t\n", "
\n", "
\n", "
\n", "
\n", " title1\n", "
\n", "
\n", " title2\n", "
\n", "
\n", " title3\n", "
\n", "
\n", " title4\n", "
\n", "
\n", "
\n", "
\n", " title1\n", "
\n", "\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", " \n" ], "text/plain": [ "HTML{String}(\"
\\n
\\n
\\n
\\n y\\n
\\n
\\n 5\\n
\\n\\n
\\n
\\n
\\n t\\n
\\n
\\n
\\n
\\n title1\\n
\\n
\\n title2\\n
\\n
\\n title3\\n
\\n
\\n title4\\n
\\n
\\n
\\n
\\n title1\\n
\\n\\n
\\n
\\n\\n
\\n
\\n
\\n \\n\")" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " var _guiBootup = function (curCallback) {\n", " Jupyter.notebook.kernel.comm_manager.unregister_target(\"interact-5aca08c4-f8c3-4666-978f-bf3d93a7971d\")\n", " Jupyter.notebook.kernel.comm_manager.register_target(\"interact-5aca08c4-f8c3-4666-978f-bf3d93a7971d\", function (comm, msg) {\n", " globalComms[\"interact-5aca08c4-f8c3-4666-978f-bf3d93a7971d\"] = comm;\n", "\n", " comm.on_msg(function(msg) {\n", " if ( \"json\" in msg.content.data ) {\n", " var workPlot = $(\"#js-interact__5aca08c4-f8c3-4666-978f-bf3d93a7971d .js-plotly-plot\")[0];\n", " if ( typeof workPlot === \"undefined\" ) { alert(\"Could not find plotly plot!\"); }\n", "\n", " var workJson = msg.content.data.json.plot;\n", " customPlotlyReact(workPlot, workJson.data, workJson.layout, workJson.config);\n", "\n", " $(\"#js-interact__5aca08c4-f8c3-4666-978f-bf3d93a7971d .js-new-plot-script\").replaceWith(msg.content.data.json.script);\n", " } else {\n", " if ( \"html\" in msg.content.data ) {\n", " var tmpDisplay = $(\"#js-interact__5aca08c4-f8c3-4666-978f-bf3d93a7971d .js-display\");\n", " tmpDisplay.html(msg.content.data.html);\n", " } else {\n", " if ( \"text\" in msg.content.data ) {\n", " console.log(msg.content.data.text);\n", " } else {\n", " alert(\"Unrecognized interact content type!\");\n", " }\n", " }\n", " }\n", " });\n", "\n", " comm.on_close(function(msg) { console.log(\"Julia close message: \" + msg); });\n", " $(\"#js-interact__5aca08c4-f8c3-4666-978f-bf3d93a7971d\").trigger(\"interact\");\n", " })\n", "\n", " var curCommand = 'Main.SimplePlots.interact_comms[\"interact-5aca08c4-f8c3-4666-978f-bf3d93a7971d\"][] += 10';\n", " Jupyter.notebook.kernel.execute(curCommand, {\"iopub\": {\"output\": function(tmpMessage) {\n", " console.log(tmpMessage)\n", " }}});\n", "\n", " if ( typeof curCallback !== \"undefined\" ) { curCallback(); }\n", " }\n", "\n", " if ( typeof Jupyter === \"undefined\" ) {\n", " customPlotLoader(function() {\n", " $(\"#js-interact__5aca08c4-f8c3-4666-978f-bf3d93a7971d\").trigger(\"interact\");\n", " });\n", " } else {\n", " if (Jupyter.notebook.kernel) {\n", " _guiBootup()\n", " } else {\n", " Jupyter.notebook.events.one('kernel_ready.Kernel', (e) => {\n", " _guiBootup(function() {\n", " customPlotLoader(function() {\n", " $(\"#js-interact__5aca08c4-f8c3-4666-978f-bf3d93a7971d\").trigger(\"interact\");\n", " });\n", " });\n", " });\n", " }\n", " }\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " 1.158011 seconds (3.22 M allocations: 154.353 MiB, 3.25% gc time)\n" ] } ], "source": [ "function bar()\n", " yy = rand(10)\n", " xx = slider(2:6, value=5, label=\"y\")\n", " SimplePlots.@gui for x in xx, t = \"title\" .* string.(1:4)\n", " plot(x .* 1:10, yy, title=t)\n", " end\n", "end\n", "\n", "@time bar()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "
\n", "
\n", "
\n", " y\n", "
\n", "
\n", " 5\n", "
\n", "\n", "
\n", "
\n", "
\n", " t\n", "
\n", "
\n", "
\n", "
\n", " title1\n", "
\n", "
\n", " title2\n", "
\n", "
\n", " title3\n", "
\n", "
\n", " title4\n", "
\n", "
\n", "
\n", "
\n", " title1\n", "
\n", "\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", " \n" ], "text/plain": [ "HTML{String}(\"
\\n
\\n
\\n
\\n y\\n
\\n
\\n 5\\n
\\n\\n
\\n
\\n
\\n t\\n
\\n
\\n
\\n
\\n title1\\n
\\n
\\n title2\\n
\\n
\\n title3\\n
\\n
\\n title4\\n
\\n
\\n
\\n
\\n title1\\n
\\n\\n
\\n
\\n\\n
\\n
\\n
\\n \\n\")" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " var _guiBootup = function (curCallback) {\n", " Jupyter.notebook.kernel.comm_manager.unregister_target(\"interact-3c87f24f-be0d-4e15-9d18-f72ee68af9e9\")\n", " Jupyter.notebook.kernel.comm_manager.register_target(\"interact-3c87f24f-be0d-4e15-9d18-f72ee68af9e9\", function (comm, msg) {\n", " globalComms[\"interact-3c87f24f-be0d-4e15-9d18-f72ee68af9e9\"] = comm;\n", "\n", " comm.on_msg(function(msg) {\n", " if ( \"json\" in msg.content.data ) {\n", " var workPlot = $(\"#js-interact__3c87f24f-be0d-4e15-9d18-f72ee68af9e9 .js-plotly-plot\")[0];\n", " if ( typeof workPlot === \"undefined\" ) { alert(\"Could not find plotly plot!\"); }\n", "\n", " var workJson = msg.content.data.json.plot;\n", " customPlotlyReact(workPlot, workJson.data, workJson.layout, workJson.config);\n", "\n", " $(\"#js-interact__3c87f24f-be0d-4e15-9d18-f72ee68af9e9 .js-new-plot-script\").replaceWith(msg.content.data.json.script);\n", " } else {\n", " if ( \"html\" in msg.content.data ) {\n", " var tmpDisplay = $(\"#js-interact__3c87f24f-be0d-4e15-9d18-f72ee68af9e9 .js-display\");\n", " tmpDisplay.html(msg.content.data.html);\n", " } else {\n", " if ( \"text\" in msg.content.data ) {\n", " console.log(msg.content.data.text);\n", " } else {\n", " alert(\"Unrecognized interact content type!\");\n", " }\n", " }\n", " }\n", " });\n", "\n", " comm.on_close(function(msg) { console.log(\"Julia close message: \" + msg); });\n", " $(\"#js-interact__3c87f24f-be0d-4e15-9d18-f72ee68af9e9\").trigger(\"interact\");\n", " })\n", "\n", " var curCommand = 'Main.SimplePlots.interact_comms[\"interact-3c87f24f-be0d-4e15-9d18-f72ee68af9e9\"][] += 10';\n", " Jupyter.notebook.kernel.execute(curCommand, {\"iopub\": {\"output\": function(tmpMessage) {\n", " console.log(tmpMessage)\n", " }}});\n", "\n", " if ( typeof curCallback !== \"undefined\" ) { curCallback(); }\n", " }\n", "\n", " if ( typeof Jupyter === \"undefined\" ) {\n", " customPlotLoader(function() {\n", " $(\"#js-interact__3c87f24f-be0d-4e15-9d18-f72ee68af9e9\").trigger(\"interact\");\n", " });\n", " } else {\n", " if (Jupyter.notebook.kernel) {\n", " _guiBootup()\n", " } else {\n", " Jupyter.notebook.events.one('kernel_ready.Kernel', (e) => {\n", " _guiBootup(function() {\n", " customPlotLoader(function() {\n", " $(\"#js-interact__3c87f24f-be0d-4e15-9d18-f72ee68af9e9\").trigger(\"interact\");\n", " });\n", " });\n", " });\n", " }\n", " }\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " 0.018448 seconds (33.01 k allocations: 1.935 MiB)\n" ] } ], "source": [ "function baz()\n", " yy = rand(10)\n", " xx = slider(2:6, value=5, label=\"y\")\n", " SimplePlots.@manipulate for x in xx, t = \"title\" .* string.(1:4)\n", " plot(x .* 1:10, yy, title=t)\n", " end\n", "end\n", "\n", "@time baz()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "
\n", "
\n", "
\n", " x\n", "
\n", "
\n", " 2\n", "
\n", "\n", "
\n", "
\n", "
\n", " t\n", "
\n", "
\n", "
\n", "
\n", " title 1\n", "
\n", "
\n", " title 2\n", "
\n", "
\n", "
\n", "
\n", " title 1\n", "
\n", "\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", " \n" ], "text/plain": [ "HTML{String}(\"
\\n
\\n
\\n
\\n x\\n
\\n
\\n 2\\n
\\n\\n
\\n
\\n
\\n t\\n
\\n
\\n
\\n
\\n title 1\\n
\\n
\\n title 2\\n
\\n
\\n
\\n
\\n title 1\\n
\\n\\n
\\n
\\n\\n
\\n
\\n
\\n \\n\")" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " var _guiBootup = function (curCallback) {\n", " Jupyter.notebook.kernel.comm_manager.unregister_target(\"interact-9909cc7f-f42e-4deb-bcf6-545b7b40f2ce\")\n", " Jupyter.notebook.kernel.comm_manager.register_target(\"interact-9909cc7f-f42e-4deb-bcf6-545b7b40f2ce\", function (comm, msg) {\n", " globalComms[\"interact-9909cc7f-f42e-4deb-bcf6-545b7b40f2ce\"] = comm;\n", "\n", " comm.on_msg(function(msg) {\n", " if ( \"json\" in msg.content.data ) {\n", " var workPlot = $(\"#js-interact__9909cc7f-f42e-4deb-bcf6-545b7b40f2ce .js-plotly-plot\")[0];\n", " if ( typeof workPlot === \"undefined\" ) { alert(\"Could not find plotly plot!\"); }\n", "\n", " var workJson = msg.content.data.json.plot;\n", " customPlotlyReact(workPlot, workJson.data, workJson.layout, workJson.config);\n", "\n", " $(\"#js-interact__9909cc7f-f42e-4deb-bcf6-545b7b40f2ce .js-new-plot-script\").replaceWith(msg.content.data.json.script);\n", " } else {\n", " if ( \"html\" in msg.content.data ) {\n", " var tmpDisplay = $(\"#js-interact__9909cc7f-f42e-4deb-bcf6-545b7b40f2ce .js-display\");\n", " tmpDisplay.html(msg.content.data.html);\n", " } else {\n", " if ( \"text\" in msg.content.data ) {\n", " console.log(msg.content.data.text);\n", " } else {\n", " alert(\"Unrecognized interact content type!\");\n", " }\n", " }\n", " }\n", " });\n", "\n", " comm.on_close(function(msg) { console.log(\"Julia close message: \" + msg); });\n", " $(\"#js-interact__9909cc7f-f42e-4deb-bcf6-545b7b40f2ce\").trigger(\"interact\");\n", " })\n", "\n", " var curCommand = 'Main.SimplePlots.interact_comms[\"interact-9909cc7f-f42e-4deb-bcf6-545b7b40f2ce\"][] += 10';\n", " Jupyter.notebook.kernel.execute(curCommand, {\"iopub\": {\"output\": function(tmpMessage) {\n", " console.log(tmpMessage)\n", " }}});\n", "\n", " if ( typeof curCallback !== \"undefined\" ) { curCallback(); }\n", " }\n", "\n", " if ( typeof Jupyter === \"undefined\" ) {\n", " customPlotLoader(function() {\n", " $(\"#js-interact__9909cc7f-f42e-4deb-bcf6-545b7b40f2ce\").trigger(\"interact\");\n", " });\n", " } else {\n", " if (Jupyter.notebook.kernel) {\n", " _guiBootup()\n", " } else {\n", " Jupyter.notebook.events.one('kernel_ready.Kernel', (e) => {\n", " _guiBootup(function() {\n", " customPlotLoader(function() {\n", " $(\"#js-interact__9909cc7f-f42e-4deb-bcf6-545b7b40f2ce\").trigger(\"interact\");\n", " });\n", " });\n", " });\n", " }\n", " }\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "demoData['interact-9909cc7f-f42e-4deb-bcf6-545b7b40f2ce'] = {\"1\":{\"title 1\":{\"config\":{\"responsive\":true},\"data\":[{\"line\":{\"color\":\"#636EFA\"},\"mode\":\"lines\",\"x\":[1,2,3,4,5,6,7,8,9,10],\"y\":[0.5283458013390012,0.445468900559562,0.6520315325057773,0.4568986175408982,0.14783891304163022,0.5721007127127389,0.5598880786375717,0.2764344611437506,0.925913968201189,0.9176592375940789]}],\"layout\":{\"showlegend\":true,\"xaxis\":{\"autorange\":true,\"type\":\"linear\"},\"annotations\":[],\"title\":\"title 1\",\"yaxis\":{\"autorange\":true,\"type\":\"linear\"},\"shapes\":[],\"legend\":{}}},\"title 2\":{\"config\":{\"responsive\":true},\"data\":[{\"line\":{\"color\":\"#636EFA\"},\"mode\":\"lines\",\"x\":[1,2,3,4,5,6,7,8,9,10],\"y\":[0.5283458013390012,0.445468900559562,0.6520315325057773,0.4568986175408982,0.14783891304163022,0.5721007127127389,0.5598880786375717,0.2764344611437506,0.925913968201189,0.9176592375940789]}],\"layout\":{\"showlegend\":true,\"xaxis\":{\"autorange\":true,\"type\":\"linear\"},\"annotations\":[],\"title\":\"title 2\",\"yaxis\":{\"autorange\":true,\"type\":\"linear\"},\"shapes\":[],\"legend\":{}}}},\"2\":{\"title 1\":{\"config\":{\"responsive\":true},\"data\":[{\"line\":{\"color\":\"#636EFA\"},\"mode\":\"lines\",\"x\":[2,3,4,5,6,7,8,9,10],\"y\":[0.5283458013390012,0.445468900559562,0.6520315325057773,0.4568986175408982,0.14783891304163022,0.5721007127127389,0.5598880786375717,0.2764344611437506,0.925913968201189,0.9176592375940789]}],\"layout\":{\"showlegend\":true,\"xaxis\":{\"autorange\":true,\"type\":\"linear\"},\"annotations\":[],\"title\":\"title 1\",\"yaxis\":{\"autorange\":true,\"type\":\"linear\"},\"shapes\":[],\"legend\":{}}},\"title 2\":{\"config\":{\"responsive\":true},\"data\":[{\"line\":{\"color\":\"#636EFA\"},\"mode\":\"lines\",\"x\":[2,3,4,5,6,7,8,9,10],\"y\":[0.5283458013390012,0.445468900559562,0.6520315325057773,0.4568986175408982,0.14783891304163022,0.5721007127127389,0.5598880786375717,0.2764344611437506,0.925913968201189,0.9176592375940789]}],\"layout\":{\"showlegend\":true,\"xaxis\":{\"autorange\":true,\"type\":\"linear\"},\"annotations\":[],\"title\":\"title 2\",\"yaxis\":{\"autorange\":true,\"type\":\"linear\"},\"shapes\":[],\"legend\":{}}}},\"3\":{\"title 1\":{\"config\":{\"responsive\":true},\"data\":[{\"line\":{\"color\":\"#636EFA\"},\"mode\":\"lines\",\"x\":[3,4,5,6,7,8,9,10],\"y\":[0.5283458013390012,0.445468900559562,0.6520315325057773,0.4568986175408982,0.14783891304163022,0.5721007127127389,0.5598880786375717,0.2764344611437506,0.925913968201189,0.9176592375940789]}],\"layout\":{\"showlegend\":true,\"xaxis\":{\"autorange\":true,\"type\":\"linear\"},\"annotations\":[],\"title\":\"title 1\",\"yaxis\":{\"autorange\":true,\"type\":\"linear\"},\"shapes\":[],\"legend\":{}}},\"title 2\":{\"config\":{\"responsive\":true},\"data\":[{\"line\":{\"color\":\"#636EFA\"},\"mode\":\"lines\",\"x\":[3,4,5,6,7,8,9,10],\"y\":[0.5283458013390012,0.445468900559562,0.6520315325057773,0.4568986175408982,0.14783891304163022,0.5721007127127389,0.5598880786375717,0.2764344611437506,0.925913968201189,0.9176592375940789]}],\"layout\":{\"showlegend\":true,\"xaxis\":{\"autorange\":true,\"type\":\"linear\"},\"annotations\":[],\"title\":\"title 2\",\"yaxis\":{\"autorange\":true,\"type\":\"linear\"},\"shapes\":[],\"legend\":{}}}}}\n", " $(\"#js-interact__9909cc7f-f42e-4deb-bcf6-545b7b40f2ce\").trigger(\"interact\");\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " 1.582 seconds\n" ] } ], "source": [ "using Dates\n", "init_time = Dates.now()\n", "\n", "yy = rand(10)\n", "SimplePlots.@demo for x in 1:3, t in [\"title 1\", \"title 2\"]\n", " plot(x .* 1:10, yy, title=t)\n", " sleep(1/3)\n", "end\n", "\n", "run_time = ( ( Dates.now() - init_time ) / ( Millisecond(1) * 1000) ) - 2.0\n", "println(\" $(round(run_time,digits=8)) seconds\")" ] } ], "metadata": { "@webio": { "lastCommId": null, "lastKernelId": null }, "kernelspec": { "display_name": "Julia 1.4.0", "language": "julia", "name": "julia-1.4" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.4.0" } }, "nbformat": 4, "nbformat_minor": 4 }