Tabula Rasa » Python
home mail us syndication

Archive for Python

Crazy Matplotlib tutorial

I started using python’s matplotlib to plot graphs in my Oceanography courses. Matplotlib is pretty easy to understand if you already know some python. However it’s documentation is somewhat frustrating, even though it comes with a plethora of examples.

So I turned to seek help on the user’s list, and that was a great experience. I got responses almost immediately, and many times the respondent was the author of the program himself. That was very nice, but people kept telling me I should read the tutorial and user guide and I kept answering that I prefer to learn by doing. Which is true. I use another program which has a steep learning curve called latex-beamer. It comes with a wonderful 300+ pages user guide. I read bits and parts of it. But mostly, I just saw other people code and copied it and changed it to fit my own presentation needs. Unfortunately, I couldn’t do the same with Matplotlib, maybe because graph codes is not something people show around like beamer presentation.

So I ended up quite frustrated and I wrote the following to the mailing list:

I am a lost case about reading tutorial at the moment.
I am in a middle of a very intense course, and they expect us to do crazy stuff with matlab. so it’s either that or solving with python. I’ll do read it when I have time…

I am mostly frustrated with documentation writers who write very nice tutorials describing
how to plot completely unuseful graphs of spheres inside loops and a dolphin swimming
in the middle. Come on, this is not what users need. I am talking about what many students
feel. We need real tutorials, this why I wrote my own little tutorial here

So I vented a lit bit my frustration. The reply didn’t wait long before arriving in a very funny way:

Read the rest of this entry »

Data analysis with Programming

Last time I wrote about the disadventages of using a spreadsheet program to analyze large amounts of data, espcially when it comes to important data. Well, as I already said I decided to learn some programming language to do the task. So last week I was working on my homework in the course of Oceanography. Our teacher gave us an excel file containing oceanographic data from the Red Sea, Golf of Eilat (or Aqaba if you prefer). Our task was to present graphs of salinty and potential temperatue, and potential vs. pressure and do some oher calculations regarding our course. So I found my self dragging my mouse endlessly and fighting with excel to plot those graphs. I personally prefer working with Gnumeric, but this file contained some macros to calculate the potential density of the water. So after I submitted the excercise I decided it is time to learn a programing language to do the mission. Since I aleady know python, I thought that matplotlib will be a good choice.

What can I tell you, learning it and ploting my first graphs was quicker then opening excel any spreadsheet. The website has a really good tutorial and for advanced cases you can always get help from the freindly people on the project’s mailing list.

Here is a short tutorial describing how I did my first oceanographic plot with matplotlib. Read the rest of this entry »