{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b51b2c04fbb54c97906c10d8544e10f6", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from beakerx import *\n", "Plot(title=\"test title\",\n", " xLabel=\"x label\",\n", " yLabel=\"y label\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "47239535a9ee40d3a537c27fcab850f2", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plot1 = Plot()\n", "plot1.add(Bars(displayName=\"Bar\", \n", " x=[20,40,60], \n", " y=[100, 120, 90], \n", " width=10))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a7eb5d7e2956408a81ae939f70bf7f1f", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plot2 = Plot()\n", "plot2.add(Line(x=[1, 5, 3], y=[1, 2, 6]))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "27930abbe0344c39ae4358143fc9f620", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plot3 = Plot()\n", "plot3.add(Points(y=[1, 3, 6, 3, 1], \n", " x=[1, 2, 3, 4, 5], \n", " size=10, \n", " shape=ShapeType.DIAMOND))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "661082561b1a4d9683fc71475f8d3a15", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plot4 = Plot();\n", "plot4.add(Stems(y= [1.5, 1, 6, 5]))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "5b4cc85fa5ac4c3ea22a93de4d4b208d", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plot5 = Plot(crosshair = Crosshair())\n", "plot5.add(Area(x = [0, 1, 2, 3], y = [3, 5, 2, 3]))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a9c65082cfd54dfbac6b707a170ff66b", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Plot().add(ConstantLine(y=0.1)).add(ConstantLine(x=0.3, y=0.4, color=Color.gray, showLabel=True))" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "bde695e4e0a342c8a7850181eeb74af6", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Plot().add(Line(y=[-3, 1, 3, 4, 5])).add(ConstantBand(x=[1, 2], y=[1, 3]))" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "731f6ce3f75b4bab831c9ffe14060aba", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from beakerx.plot import Text as BeakerxText\n", "plot = Plot()\n", "xs = [1, 2, 3, 4]\n", "ys = [8.6, 6.1, 7.4, 2.5]\n", "\n", "for i in range(0, 4):\n", " plot.add(BeakerxText(x= xs[i], y= ys[i], text= 'test'))\n", "\n", "plot.add(Line(x= xs, y= ys))" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "28001f218e5e42f3b14d8408e12815a0", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import pandas as pd\n", "\n", "tableRows = pd.read_csv('../../../doc/resources/data/interest-rates.csv')\n", "pp1 = Plot()\n", "pp1.add(Bars(y=tableRows.y1))" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e3db7b3831f349b4818709191e5f918f", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "pp2 = Plot()\n", "pp2.add(Line(\n", " x=pd.Series([10, 20, 30, 40, 50, 60, 70]), \n", " y=pd.Series([0, 60, 10, 50, 20, 40, 30]), \n", " width=5))" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f3d0e4f7e9cf467aa2243f127d866ee5", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "y1 = [1,5,3,2,3]\n", "y2 = [1,2,4,1,3]\n", "p = Plot()\n", "a1 = Area(y=y1, displayName='y1')\n", "a2 = Area(y=y2, displayName='y2')\n", "stacker = XYStacker()\n", "p.add(stacker.stack([a1, a2]))" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "7570a316b1cb4f829e62aac1332368b7", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "SimpleTimePlot(tableRows, [\"y1\", \"y10\"], # column names\n", " timeColumn=\"time\", # time is default value for a timeColumn\n", " displayNames=[\"1 Year\", \"10 Year\"])" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "de31adce0a1a4f15ad55d3743545acd7", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import time\n", "\n", "millis = 1507541201624;\n", "hour = round(1000 * 60 * 60);\n", "xs = [];\n", "ys = [];\n", "for i in range(11):\n", " xs.append(millis + hour * i);\n", " ys.append(i);\n", "\n", "plot = TimePlot(timeZone=\"America/New_York\")\n", "# list of milliseconds\n", "plot.add(Points(x=xs, y=ys))" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "539b6e98ed774879a89d89d16c48859b", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "millis = millis = 1507541201624;\n", "nanos = millis * 1000 * 1000\n", "xs = []\n", "ys = []\n", "for i in range(11):\n", " xs.append(nanos + 7 * i)\n", " ys.append(i);\n", "\n", "np = NanoPlot()\n", "np.add(Points(x=xs, y=ys))" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "4e8b4cd3daaa4edb8edaca163009d94f", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "sp = Plot()\n", "sp.add(YAxis(label= \"Test y axis\"))\n", "sp.add(Line(\n", " x=pd.Series([10, 20, 30, 40, 50, 60, 70]), \n", " y=pd.Series([0, 60, 10, 50, 20, 40, 30])))\n", "sp.add(Line(\n", " x=pd.Series([5, 15, 25, 35, 45, 55, 65]), \n", " y=pd.Series([5, 65, 15, 55, 25, 45, 35]), yAxis= \"Test y axis\"))" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ab97f6f6b64842779f1da74def249aa7", "version_major": 2, "version_minor": 0 } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import math\n", "points = 100;\n", "xs = [];\n", "for i in range(0, points):\n", " xs.append(i)\n", "\n", "cplot = CombinedPlot(xLabel= \"CombinedPlot\");\n", "\n", "linearPlot = Plot(title= \"Linear x, Linear y\");\n", "linearPlot.add(Line(x= xs, y= xs));\n", "cplot.add(linearPlot, 3);\n", "\n", "logYPlot = Plot(logY= True, logX=False, title= \"Linear x, Log y\");\n", "logYPlot.add(Line(x= xs, y= xs));\n", "cplot.add(logYPlot, 3);\n", "\n", "logYPlot = Plot(logY= False, logX=True, title= \"Log x, Linear y\");\n", "logYPlot.add(Line(x= xs, y= xs));\n", "cplot.add(logYPlot, 3);\n", "\n", "cplot\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.2" } }, "nbformat": 4, "nbformat_minor": 1 }