Commit a9ad2ce8 authored by Marc Gouw's avatar Marc Gouw

Small changes and edits to Worksheet 4.

parent 4dc111d0
......@@ -14,17 +14,6 @@
"## 4. Plotting Data with Matplotlib and Bokeh"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"% matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -36,7 +25,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"What we have been doing so far has required you to type the data into the programs by hand, which is a bit cruel. For this worksheet, we will be using a larger dataset (still tiny by many standards) and you can download a file containing the data from the [GitHub repository](https://github.com/tobyhodges/ITPP/blob/master/speciesDistribution.txt) where these teaching materials are maintained. Just right-click 'Raw' at the top of the file content and download/save the linked file into the same directory as you are keeping the Python scripts. (_Note: if you already obtained these materials from the repository, you probably downloaded the data file, into the same folder, at the same time._)"
"What we have been doing so far has required you to type the data into the programs by hand, which is a bit cruel. For this worksheet, we will be using a larger dataset (still tiny by many standards) and you can download a file containing the data from the [GitHub repository](https://git.embl.de/grp-bio-it/ITPP/blob/master/speciesDistribution.txt) where these teaching materials are maintained. Just right-click 'Raw' at the top of the file content and download/save the linked file into the same directory as you are keeping the Python scripts. (_Note: if you already obtained these materials from the repository, you probably downloaded the data file, into the same folder, at the same time._)"
]
},
{
......@@ -82,11 +71,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
"lines = f.readlines()"
"lines = f.readlines()\n",
"lines"
]
},
{
......@@ -711,6 +701,10 @@
},
"outputs": [],
"source": [
"% magic inline\n",
"# The above line is a 'magic' line for the Jupyter notebook which allows plots to be placed inside of the notebook.\n",
"# Make sure to place this line before importing matplotlib/pyplot.\n",
"\n",
"import numpy as np\n",
"from matplotlib import pyplot as plt"
]
......@@ -905,7 +899,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
......@@ -1152,7 +1146,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The `charts` library also contains several other functions for common types of plot, and `bokeh.io` provides functions to display these plots together. For example, below we will create a scatter plot and display that alongside our bar chart in the output:"
"The `charts` library also contains several other functions for common types of plot, and `bokeh.models.layours` provides functions to display these plots together. For example, below we will create a scatter plot and display that alongside our bar chart in the output:"
]
},
{
......@@ -1164,13 +1158,13 @@
"outputs": [],
"source": [
"from bokeh.charts import Scatter\n",
"from bokeh.io import hplot\n",
"from bokeh.models.layouts import Row\n",
"data2 = {'X': [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7],\n",
" 'Y': [1,2,1,2,1,2,1,2,3,1,2,3,3,3,2,1],\n",
" 'S': ['A','A','A','A','A','A','A','A','B','B','B','B','B','B','B','B']}\n",
"print(data2)\n",
"mySecondPlot = Scatter(data2, x='X', y='Y', color='S', legend='top_right')\n",
"layout = hplot(myFirstPlot, mySecondPlot)\n",
"layout = Row(myFirstPlot, mySecondPlot)\n",
"show(layout)"
]
},
......@@ -1256,7 +1250,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.1"
"version": "3.6.0"
}
},
"nbformat": 4,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment