diff --git a/core/charts.md b/core/charts.md index faa2c94..6b94aa9 100644 --- a/core/charts.md +++ b/core/charts.md @@ -41,7 +41,8 @@ You can add this as a new cell in your notebook: plt.bar(x, votes) plt.xticks(x + 0.5, names, rotation=90) -* TODO Picture +Radishes on a bargraph + There's a lot going on here so we'll go through it line by line. Don't be afraid to add `print()` statements, or tweak some of the values, or comment out certain lines (like the xticks line) and rerun the code in order to figure out what's going on here. @@ -70,13 +71,15 @@ We create a range of indexes for the X values in the graph, one entry for each e plt.bar(x, votes) -* TODO image showing just the bar section +Bar section + `plt.bar()` creates a bar graph, using the "x" values as the X axis positions and the values in the votes array (ie the vote counts) as the height of each bar. plt.xticks(x + 0.5, names, rotation=90) -* TODO image showing just the ticks +Ticks section + `plt.xticks()` specifies a range of values to use as labels ("ticks") for the X axis. @@ -86,6 +89,12 @@ This means that `0,1,2,3`,etc. becomes `0.5,1.5,2.5,3.5`,etc. This is what posit Finally, `rotation=90` ensures that the labels are drawn sideways (90 degree angle) not straight. You can experiment with different rotations to create different effects. +## Challenge + +There's no label on the Y axis showing that it represents the vote count. + +Can you update your bar graph code so it does this? Take a look at the [ylabel() function in the pyplot documentation](http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.ylabel). + ## Advanced Charting diff --git a/core/csv.md b/core/csv.md index 78b4935..44adf83 100644 --- a/core/csv.md +++ b/core/csv.md @@ -42,6 +42,8 @@ There are a few good reasons to use the CSV module here: We're going to do some processing of real-world data now, using freely available airline data sets from the [OpenFlights project](http://www.openflights.org/). +**TIP:** As we're moving on from radishes to aircraft, now is a good time to start a new notebook in IPython Notebook (under File->New) to keep everything organised. Don't forget to save your old notebook! + Visit the [OpenFlights data page](http://openflights.org/data.html) and download their airports data file - "airports.dat". This is a file in CSV format. Can you use this file to print all of the airport names for a particular country (say, Australia or Russia)? @@ -105,7 +107,7 @@ Look back at the [OpenFlights data page](http://www.openflights.org/data.html) t To see the contents of the latitudes or longitudes dictionaries, just type the variable name into a cell and run it. -Viewing latitudes in a Notebook cell +Viewing latitudes in a Notebook cell There's one new thing in this example solution: `float(row[6])`. `float()` means to convert the string value to a floating point (ie fractional) number: @@ -153,7 +155,7 @@ When looking at the list of fields in the OpenFlights data documentation, rememb Once again, you can test the results of your program by typing the name of the output list (`distances` in this case) into an IPython Notebook cell and running it: -Viewing latitudes in a Notebook cell +Viewing latitudes in a Notebook cell ## Histogram @@ -168,7 +170,7 @@ Now we're ready to create a histogram displaying the frequency of flights by dis plt.ylabel("Number of flights") -Airline route distance histogram +Airline route distance histogram `plt.hist()` does most of the work here. The first argument we supply is the dataset (list of distances.) diff --git a/core/notebook.md b/core/notebook.md index a036b82..7227d68 100644 --- a/core/notebook.md +++ b/core/notebook.md @@ -10,9 +10,10 @@ title: Introducing IPython Notebook Until now we've worked with Python either directly via the interactive Python console, or by writing Python programs using a text editor. -However, there are other ways to work with Python. [IPython](http://ipython.org/) is a set of tools originally developed to make it easier for scientists to work with Python and data. It allows you to combine interactive Python exploration with prewritten programs. +However, there are other ways to work with Python. [IPython](http://ipython.org/) is a set of tools originally developed to make it easier for scientists to work with Python and data. It allows you to combine interactive Python exploration with prewritten programs and even text and equations for documentation. -* TODO picture +A sample from the IPython Notebook introduction examples + # Installing IPython Notebook @@ -148,8 +149,7 @@ Installers like 'Anaconda' will add IPython Notebook to your system path, which * In previous workshops we used `help()` to view help information in the Python interpreter. IPython Notebook makes this even simpler, you can just type the name of a Python function or module and end it with a `?`. Try it now, type `print?` into a cell and run it. -* Using a nifty tool called NBViewer you can easily share TODO TODO - +* Using a nifty tool called NBViewer you can easily share IPython Notebooks on the internet, rendered as web pages (but still downloadable to play with in IPython.) Check out the [NBViewer home page](http://nbviewer.ipython.org/) or the [IPython Notebook gallery](https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-IPython-Notebooks) for some interesting starting points diff --git a/images/assign_shopping_list.png b/images/assign_shopping_list.png new file mode 100644 index 0000000..9f2c16e Binary files /dev/null and b/images/assign_shopping_list.png differ diff --git a/files/histogram.png b/images/histogram.png similarity index 100% rename from files/histogram.png rename to images/histogram.png diff --git a/images/ipython_example.png b/images/ipython_example.png new file mode 100644 index 0000000..a8286c1 Binary files /dev/null and b/images/ipython_example.png differ diff --git a/images/ipython_notebook.png b/images/ipython_notebook.png new file mode 100644 index 0000000..9407fa9 Binary files /dev/null and b/images/ipython_notebook.png differ diff --git a/images/notebook_hello_world.png b/images/notebook_hello_world.png new file mode 100644 index 0000000..50f4801 Binary files /dev/null and b/images/notebook_hello_world.png differ diff --git a/images/print_shopping_list.png b/images/print_shopping_list.png new file mode 100644 index 0000000..f11b179 Binary files /dev/null and b/images/print_shopping_list.png differ diff --git a/images/radish_bargraph.png b/images/radish_bargraph.png new file mode 100644 index 0000000..5f8871b Binary files /dev/null and b/images/radish_bargraph.png differ diff --git a/images/radish_barsection.png b/images/radish_barsection.png new file mode 100644 index 0000000..a965ba4 Binary files /dev/null and b/images/radish_barsection.png differ diff --git a/images/radish_ticks.png b/images/radish_ticks.png new file mode 100644 index 0000000..6a96667 Binary files /dev/null and b/images/radish_ticks.png differ diff --git a/files/viewing_distances.png b/images/viewing_distances.png similarity index 100% rename from files/viewing_distances.png rename to images/viewing_distances.png diff --git a/files/viewing_latitudes.png b/images/viewing_latitudes.png similarity index 100% rename from files/viewing_latitudes.png rename to images/viewing_latitudes.png