Commit 062c5cef authored by Toby Hodges's avatar Toby Hodges
Browse files

merged updated Bokeh exercise walkthrough from MPLandBokehPlotting branch.

parents 7dbdd584 01e10305
This diff is collapsed.
......@@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. Nested Data Structures"
"## 3. Nested Data Structures"
]
},
{
......@@ -127,7 +127,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"but you might not want to lose track of which students belong to which class. So instead, it is a good idea to store the individual lists as entries in another data structure that can be processed iteratively just like the lists themselves. We have a few options here, but let's begin with the most obvious: we can create a list of lists - where each entry in the list is itself another list:"
"but you might not want to lose track of which students belong to which class. So instead, it is a good idea to store the individual lists as entries in another data structure that can be processed iteratively just like the lists themselves. We have a few options here, but let's begin with a list of lists - where each entry in the list is itself another list:"
]
},
{
......@@ -176,7 +176,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### _Exercise 4.1_"
"#### _Exercise 3.1_"
]
},
{
......@@ -326,7 +326,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### _Exercise 4.2_"
"#### _Exercise 3.2_"
]
},
{
......@@ -505,7 +505,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### _Exercise 4.3_"
"#### _Exercise 3.3_"
]
},
{
......@@ -541,7 +541,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### _Exercise 4.4_"
"#### _Exercise 3.4_"
]
},
{
......@@ -566,31 +566,6 @@
"| >79: | 'Congratulations! That's an excellent score!' |"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# This is my solution. To be removed.\n",
"myName = 'Toby Hodges'\n",
"for group in sorted(AllGroupResults.keys()):\n",
" for student in AllGroupResults[group]:\n",
" print('Dear {},'.format(student))\n",
" mark = AllGroupResults[group][student]\n",
" print('I have finished marking the assessment for your seminar group, {}. You scored {}'.format(group, mark))\n",
" if mark < 60:\n",
" print(\"You must try harder next time. Are you taking this course seriously?\")\n",
" elif 60 <= mark < 80:\n",
" print(\"Well done, that's a good score.\")\n",
" elif mark >= 80:\n",
" print(\"Congratulations! That's an excellent score!\")\n",
" print(\"Kind regards,\")\n",
" print('{}\\n'.format(myName))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -103,29 +103,6 @@
"The `Bar` function, and other plotting functions from `bokeh`, expect an iterable data type to plot from. Here, we will create another dictionary, keyed by site name as before but only containing the counts in a list (ordered by taxon id as before). This is slightly clumsy - given that we have already gone to so much trouble to create our dictionary of dictionaries above - but it is good to have a single structure that holds all of our data, and a separate one that contains only the data for plotting. If you'd like to learn more advanced ways of handling and processing data in Python, I recommend reading about [pandas](http://pandas.pydata.org) and [object class definitions](https://docs.python.org/3.5/tutorial/classes.html#a-first-look-at-classes)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"data = {}\n",
"for site in siteNames:\n",
" data[site] = []\n",
" for taxon in taxa:\n",
" data[site].append(sites[site][taxon])\n",
"data['taxa'] = taxa\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now to make sure that the plots render within this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
......@@ -170,6 +147,11 @@
"source": [
"plots = []\n",
"for site in siteNames:\n",
" data = {}\n",
" data[site] = []\n",
" data['taxa'] = taxa\n",
" for taxon in taxa:\n",
" data[site].append(sites[site][taxon])\n",
" plot = Bar(data, 'taxa', values=site, color='taxa', title=site, xlabel='taxon', ylabel='abundance', tools='')\n",
" plots.append(plot)"
]
......
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