matplotlib

Yes, I love python. However, I am no expert. Most of the stuff I write in python is dirty and ugly code. Sometimes I figure out new things (things that programmers already know) and sometimes I forget these things. So, here are a few tips and tricks that I use from time to time. Really, I am writing this for future Rhett when he does a google search for "how do you save data to a file in python". Saving data to a file Suppose I am modeling a basketball falling through the air. I want to plot this data, so I save position and time data in lists. For example: Here is the info from scipy…
Here is part of a picture some of my friends posted from a recent high school reunion. It may be hard to tell, but this is part of a picture of 7 females all wearing black. I just wanted to show you that they were indeed wearing black without giving away anymore details. If you are one of these people and you want your whole picture included, I will be happy to make that change and include your face. Anyway, my first comment was: "Wow, everyone is wearing black. Was this a planned event or was black part of the dress code?" The response was that it was just pure chance that all the women…
(alternate title: how to make pretty graphs in vpython) I am happy. Finally, I can use the visual module in python (vPython.org) and plotting with Matplotlib. Maybe this isn't such a big deal for many of you, but for me, it never worked until now. In the past, I blogged about plotting in vpython vs. matplotlib. My conclusion was that it was easier in vpython, but prettier in matplotlib. So, why not just use matplotlib? There are a couple of things that make vypthon very attractive. Vectors. Vpython has a built in vector class (or function - I don't know what I am talking about). There…
I am not a programmer. Just to be clear. I use python to get things done, but I am sure it could be done in more efficient ways. Anyway, I sure you know how much I like vpython - especially for teaching physics. However, sometimes I use it for blogging stuff also. The problem is that vpython doesn't make pretty graphs. Oh, they are quick and simple - but sometimes you want pretty also. Well, what if you just don't use vpython? Of course then I could use some other plotting package like pylab (which actually uses something else like matplotlib or something - I get confused). Or, I…