Basic plotting with Python
This screencast shows how to load a data file and then plot one column versus the other. For the
numpy.loadtxt command to work as shown, the data should be arranged in columns (separated by space, tabs or commas) and should comprise of floating point numbers or integers. Any headers or footers should be preceeded by a hash (‘#’).
I should have mentioned this in the last tutorial – please do not hesitate to contact me via comments regarding problems and queries.
UPDATE: Those of you on non-Mac operating systems should be aware of one thing. I didn’t realise this but when I execute a plot command in the Ipython shell on a mac, the plot shows up immediately. On Linux and Windows, you need to execute
pylab.show() after the plot command for the first plot in the session. Users can bypass this weirdness and the annoyance of always typing in
numpy. before the commands by starting Ipython in the pylab mode. This is done by typing
ipython -pylab instead of plain ole
ipython in your terminal.
Post contributed by Shrividya Ravi, VUW