Multiple XY plots

Hi,

could you use a loop to solve it?

arr1list = [np.arange(10) + i for i in range(10)]
arr2list = [np.arange(10) -i for i in range(10)]

for arr1,arr2 in zip(arr1list,arr2list):
plot(arr1,arr2)

you can use a more object oriented way:

fig = plt.figure()
ax = fig.add_subplot()
for arr1,arr2 in zip(arr1list,arr2list):
ax.plot(arr1,arr2)

code not tested.

cheers,

Chao

···

On Thu, Feb 21, 2013 at 4:17 AM, lkz2366 [via matplotlib] <[hidden email]> wrote:

I am confused on how to plot a variable number of XY plots on a single chart. I want to superimpose XY plots on a single chart but the number of plots is unknown until runtime.

For example, if I want to plot 4 plots the code would be:

figure()

plot(x1,y1,x2,y2,x3,y3,x4,y4)

show()

But the number of plots is variable and could be anywhere from 5-30. Any ideas on how I can do this?

I already have the rest of my program working. The program reads all of the data from all of the files in a target directory and writes the data to X and Y lists.

Thanks for any help.


If you reply to this email, your message will be added to the discussion below:

http://matplotlib.1069221.n5.nabble.com/Multiple-XY-plots-tp40451.html

To start a new topic under matplotlib - users, email [hidden email]

  To unsubscribe from matplotlib, click here.


  [NAML](http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml)


Chao YUE
Laboratoire des Sciences du Climat et de l’Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex

Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16



View this message in context: Re: Multiple XY plots

Sent from the matplotlib - users mailing list archive at Nabble.com.

Ok, I finally got it working after a couple of hours of experimenting. I
couldn't figure out how to get your methods to work, maybe because I'm such
a novice at Python. But, it was as easy as using a simple 'for' loop.

num = the number of lists to plot

time = a list of lists
volts = a list of lists

figure()
for x in range(0,num):
     plot(time[x],volt[x])
show()

<http://matplotlib.1069221.n5.nabble.com/file/n40498/screenshot.png>

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Multiple-XY-plots-tp40451p40498.html
Sent from the matplotlib - users mailing list archive at Nabble.com.