{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Bokeh inside SageMath 6.10 / Python 2\n", "\n", "To see the published html, goto https://cloud.sagemath.com/20e4a191-73ea-4921-80e9-0a5d792fc511/raw/bokeh/bokeh-sage-6.10.html" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'2.7.10 (default, Dec 28 2015, 04:30:58) \\n[GCC 5.2.1 20151010]'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import sys\n", "sys.version" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] }, { "data": { "text/plain": [ "'1.10.1'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "print(np)\n", "np.__version__" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'0.10.0'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import bokeh\n", "bokeh.__version__" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/ndg/httpsclient/subj_alt_name.py:22: UserWarning: Error importing pyasn1, subjectAltName check for SSL peer verification will be disabled. Import error is: No module named pyasn1.type\n", " warnings.warn(import_error_msg)\n", "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/ndg/httpsclient/ssl_peer_verification.py:25: UserWarning: SubjectAltName support is disabled - check pyasn1 package installation to enable\n", " warnings.warn(SUBJ_ALT_NAME_SUPPORT_MSG)\n", "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/ndg/httpsclient/subj_alt_name.py:22: UserWarning: Error importing pyasn1, subjectAltName check for SSL peer verification will be disabled. Import error is: No module named pyasn1.type\n", " warnings.warn(import_error_msg)\n" ] }, { "data": { "text/html": [ " \n", "\n", "\n", " \n", "\n", "
\n", " \n", " BokehJS successfully loaded.\n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from bokeh.io import output_notebook, show\n", "output_notebook()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from bokeh.plotting import figure\n", "import numpy as np\n", "\n", "x = np.linspace(0, 4*np.pi, 100)\n", "y = np.sin(x)\n", "\n", "\n", "plot = figure(title=\"Sine Function\")\n", "plot.xaxis.axis_label='x'\n", "plot.yaxis.axis_label='amplitude'\n", "\n", "\n", "plot.line(x, y, \n", " line_color='blue',\n", " line_width=2r,\n", " legend='sin(x)')\n", "\n", "plot.circle(x, 2*y, \n", " fill_color='red',\n", " line_color='black',\n", " fill_alpha=float(0.2),\n", " size=10r,\n", " legend='2sin(x)')\n", "\n", "#line_dash is an aribrary length list of lengths\n", "#alternating in [color, blank, color, ...]\n", "plot.line(x, np.sin(2*x),\n", " line_color='green',\n", " line_dash=[10r,5r,2r,5r], \n", " line_width=2r,\n", " legend='sin(2x)')\n", "\n", "show(plot)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sepal_lengthsepal_widthpetal_lengthpetal_widthspecies
05.13.51.40.2setosa
14.93.01.40.2setosa
24.73.21.30.2setosa
34.63.11.50.2setosa
45.03.61.40.2setosa
\n", "
" ], "text/plain": [ " sepal_length sepal_width petal_length petal_width species\n", "0 5.1 3.5 1.4 0.2 setosa\n", "1 4.9 3.0 1.4 0.2 setosa\n", "2 4.7 3.2 1.3 0.2 setosa\n", "3 4.6 3.1 1.5 0.2 setosa\n", "4 5.0 3.6 1.4 0.2 setosa" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from bokeh.sampledata.iris import flowers\n", "flowers.head()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/bokeh/charts/_attributes.py:78: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)\n", " df = df.sort(columns=columns)\n" ] }, { "data": { "text/html": [ "\n", "
\n", "\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from bokeh.charts import Scatter\n", "\n", "plot = Scatter(flowers, x='petal_length', y='petal_width',\n", " color='species',\n", " legend='top_left', title='Flower Morphology')\n", "show(plot)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "SageMath 6.10", "language": "", "name": "sagemath" }, "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.10" }, "name": "bokeh-sage-6.10.ipynb" }, "nbformat": 4, "nbformat_minor": 0 }