about Grigoris Maravelias
Note on how to make multiple plots with pylab

Note on how to make multiple plots with pylab

iPython is a great tool to work with Python interactively, imitating a MatLab environment especially when running with matplotlib and numpy [the pylab module, all can be automatically imported by starting pylab like: ipython –pylab]. So you can use it to load data and start playing around with them. Although I like to script more these actions it can be really fast and easy to use it when you just want to see some data and do some minor tasks. But since I don’t write them down these actions I keep forgetting them (well… after a serious number of repetitions this would be of no need … but up to that point let me keep a note!).

So, one of these is hot to make multiple plots. After creating (or most probably loading) the data and making all the necessary steps then we follow this typing:
In [23]: fig = figure()
In [24]: ax = fig.add_subplot(111)
In [25]: p1 = ax.plot(x,y,'r-')
In [26]: p2 = ax.plot(x,z,'g-')
In [27]: draw()

which gives us the following result:

Leave a Reply

Your email address will not be published. Required fields are marked *