Skip to content

Commit

Permalink
Finish off images
Browse files Browse the repository at this point in the history
  • Loading branch information
projectgus committed Jun 4, 2013
1 parent de53103 commit 381cdd6
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 10 deletions.
15 changes: 12 additions & 3 deletions core/charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<img src="../images/radish_bargraph.png" alt="Radishes on a bargraph">
</img>

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.

Expand Down Expand Up @@ -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
<img src="../images/radish_barsection.png" alt="Bar section">
</img>

`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
<img src="../images/radish_ticks.png" alt="Ticks section">
</img>

`plt.xticks()` specifies a range of values to use as labels ("ticks") for the X axis.

Expand All @@ -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

Expand Down
8 changes: 5 additions & 3 deletions core/csv.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)?
Expand Down Expand Up @@ -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.

<img src="../files/viewing_latitudes.png" alt="Viewing latitudes in a Notebook cell">
<img src="../images/viewing_latitudes.png" alt="Viewing latitudes in a Notebook cell">
</img>

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:
Expand Down Expand Up @@ -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:

<img src="../files/viewing_distances.png" alt="Viewing latitudes in a Notebook cell">
<img src="../images/viewing_distances.png" alt="Viewing latitudes in a Notebook cell">
</img>

## Histogram
Expand All @@ -168,7 +170,7 @@ Now we're ready to create a histogram displaying the frequency of flights by dis
plt.ylabel("Number of flights")


<img src="../files/histogram.png" alt="Airline route distance histogram">
<img src="../images/histogram.png" alt="Airline route distance histogram">
</img>

`plt.hist()` does most of the work here. The first argument we supply is the dataset (list of distances.)
Expand Down
8 changes: 4 additions & 4 deletions core/notebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<img src="../images/ipython_example.png" alt="A sample from the IPython Notebook introduction examples">
</img>

# Installing IPython Notebook

Expand Down Expand Up @@ -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



Expand Down
Binary file added images/assign_shopping_list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added images/ipython_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ipython_notebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/notebook_hello_world.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/print_shopping_list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/radish_bargraph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/radish_barsection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/radish_ticks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes

0 comments on commit 381cdd6

Please sign in to comment.