Exercises, examples and other material relating to training module Y118. This topic is presented on public courses Learning to program in Python
, Python Programming
Numpy is a python package for heavy numbercrunching work - written as a wrapper around the
underlying C / C++ code which allows you to get virtually the performance speed of C at the same
time as the coding speed of Python for scientific research projects which involve large amounts
of calculation. Scipy adds a wide range of statistical and mathematical algortithms, already
coded for you, on top of numpy's underlying C based objects, and matplotlib adds a very flexible
data plotting capability.
|Articles and tips on this subject||updated|
|4445||Graphing presentations in Python - huge data, numpy and matplotlib|
A picture paints a thousand words. Our server log files for February are 1.6 Gbytes in size, with 5.3 million individual requests. How busy are we at what times of day? I've been looking at this through matplotlib in Python - here's a wireframe of the month - days on the X axis, hour of the day on ...
|4440||A first graph with Matplotlib in Python|
"A picture paints a thousand words" and in Python, you can paint a graph based picture using matplotlib. Matplotlib is massive - a huge range of facilities, a 2000 page manual if you print it out - yet if you know where to start "hello graphing world" is straightforward.
Taking my previous blog example ...
|3554||Learning more about our web site - and learning how to learn about yours|
There are quite a number of tools out there which will give you statistics about your web site - and quite a lot of people who will tell you various statistics about yours and theirs. But there's "Lies, Damned lies and statistics" according to Benjamin Disraeli. How do you really understand your traffic ...
|2997||3D graphics - web site usage - simple matplotlib and python example|
Some very interesting graphs from our server log data, courtesy of Python, numpy and matplotlib. Truly, a picture paints a thousand words. The data in the first and last diagrams is raw - showing exact number of hits per hour; in other diagrams I have used proximity smoothing which makes the trends ...
|2993||Arrays v Lists - what is the difference, why use one or the other|
If you want a program to run quickly through a data set (that's the sort of thing you'll be doing in heavy scientific work), you'll want the data loaded into successive memory locations - but that means that you have to know how much space to allocate before you set the data up. Otherwise, you'll find ...
|2992||Matplotlib - graphing in Python - teaching examples|
Matplotlib provides Python with a graph drawing and data representation tool that is extremely flexible - in fact so flexible that it's hard for the newcomer to know where to start.
The following examples are very straightforward, but useful, graphs showing real data sets (from the second example onwards) ...
|2990||What are numpy and scipy?|
In Python, all the operators are really methods - in other words, you write
c = d + e
and you're really writing
c = d . __add__ ( e )
So this means that it's possible to use the language to handle data of any sort, including data types that aren't supported at standard. It's ...
|2991||Loading and saving data - Python / numpy|
If you're using big data sets in Python, you're probably using the numpy module - providing you with fast data handlers at C speed of running, and Python coding speed. But how do you load that data in? Numpy also provides a number of data handlers, data setup routines, and also a save and restore ...
Examples from our training material
|aa|| Tuple and list to numpy array conversions|
|gr3d.json|| Data for graph.py - formatted json|
|graph.py|| Graph x,y,z via numpy from a Json file|
|mpl1.py|| Hello matplotlib world|
|mpl2.py|| Plotting a user data set|
|mpl3.py|| Plotting multiple user data sets|
|mpl4.py|| Two graphs on a canvas - top to bottom|
|mpl5.py|| Two plots on a canvas - left to right|
|npgd|| Loading data into numpy|
|nphw|| Basic objects in numpy|
|npx|| Loading binary data from file into numpy array|
|npx2|| alternative scheme for loading binary data|
|prepare.py|| Extract data for graphing and save to Json|
|simplegraph|| Straightforward line plot using huge data |
|tog1.py|| Loading and storing numpy objects|
|xyz.py|| 3d and contour plots through numpy and matplotlib|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from http://www.training-notes.co.uk
Topics covered in this module
Introduction to numpy, scipy and matplotib.
Sourcing and installing numpy.
Data type wrappers - how and why.
N-Dimensional array objects.
Saving and loading - files, databases and broadcasting.
Sourcing and installing scipy.
Linear Algebra and Fourier Transform.
Random Number capabilities.
Ordinary Differential Equations (ODEs).
Sourcing and installing matplotlib.
First steps in data graphing with matplotlib.
Tuning your graphs.
Multiple plots, graphs, axes and more.
Pie, Polar, Histogram, Scatter plots, etc.
The artist around the graph.
Using matplotlib with numpy.
Using matplotlib with wxpython.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.