Multiple XY plots


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):

you can use a more object oriented way:

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

code not tested.




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:




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:

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

  To unsubscribe from matplotlib, click here.


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

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

View this message in context: Re: Multiple XY plots

Sent from the matplotlib - users mailing list archive at

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

for x in range(0,num):



View this message in context:
Sent from the matplotlib - users mailing list archive at