{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Get import" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from drawnmr import draw\n", "import nmrglue as ng\n", "import bokeh.plotting as bplt\n", "from bokeh.models import Range1d" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Get data" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Get data\n", "import os, os.path\n", "ng_dir = 'nmrglue_data/s4_2d_plotting'\n", "if not os.path.exists(ng_dir):\n", " print(\"No %s. Downloading.\"%ng_dir)\n", " import urllib.request, zipfile\n", " zipf = 'jbnmr_s4_2d_plotting.zip'\n", " urllib.request.urlretrieve('https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/nmrglue/%s'%zipf, zipf)\n", " with zipfile.ZipFile(zipf,\"r\") as zip_ref:\n", " zip_ref.extractall(\"nmrglue_data\")\n", " os.remove(zipf)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Read data" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Specify data\n", "ng_ft2 = 'nmrglue_data/s4_2d_plotting/test.ft2'\n", "\n", "# read in data\n", "ng_dic, ng_data = ng.pipe.read(ng_ft2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Create figure" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Pass to figure class\n", "fig2d = draw.fig2d(ng_dic, ng_data)\n", "# Change contour_start\n", "fig2d.contour_start = 85e3\n", "\n", "# Get the bokeh figure\n", "fig= fig2d.get_fig()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Alter figure" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Alter the figure after creation\n", "#fig.xaxis.axis_label = \"Nonsense\"\n", "\n", "# Set limits for view\n", "fig.x_range = Range1d(183.5, 167.5)\n", "fig.y_range = Range1d(139.5, 95.5)\n", "\n", "# Set larger image size\n", "fig.plot_width = 800\n", "fig.plot_height = 800" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Show output" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(root) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = true;\n", "\n", " if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " root._bokeh_onload_callbacks = [];\n", " root._bokeh_is_loading = undefined;\n", " }\n", "\n", "\n", " \n", " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", " root._bokeh_timeout = Date.now() + 5000;\n", " root._bokeh_failed_load = false;\n", " }\n", "\n", " var NB_LOAD_WARNING = {'data': {'text/html':\n", " \"\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"
\\n\"+\n", " \"\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"
\\n\"+\n",
" \"