SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: ChaoYue <cha...@gm...> - 2013年02月21日 04:35:18
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] <
ml-...@n5...> 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
> ml-...@n5...
> To unsubscribe from matplotlib, click here<http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2&code=Y2hhb3l1ZWpveUBnbWFpbC5jb218MnwxMzg1NzAzMzQx>
> .
> 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: http://matplotlib.1069221.n5.nabble.com/Multiple-XY-plots-tp40451p40453.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: lkz2366 <ac...@sa...> - 2013年02月27日 23:13:30
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.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /