## Re: [Matplotlib-users] Plotting of multiple spectras

 Re: [Matplotlib-users] Plotting of multiple spectras From: Dr. Werner Pessenhofer - 2005-04-27 13:12:55 ```Thanks for the idea ! Meanwhile I've improved it somewhat: ylen =3D shape(Ximport)[1] colors =3D ["r", "g", "b", "k", "y", "c", "m"] # And Others counter =3D 0 ind =3D 1 for ind in range(1, ylen, 2): Y =3D take(X,(0,ind), 1) x =3D Y[:,0] y =3D Y[:,1] plot(x,y,colors[counter]+'-') if counter < 5: counter =3D counter + 1 else: counter =3D 0 If my thoughts are right, this would return to beginning of colors if the= =20 last one is arrived. Regards Werner On Wed, 27 Apr 2005 14:50:49 +0200, wrote: > Hello Werner, > >> The first problem is, that all curves have the same color. Is there a > >> possibility to "rotate" the colors in the loop ? > >> while ind < 18: >> Y =3D take(X,(0,ind), 1) >> x =3D Y[:,0] >> y =3D Y[:,1] >> plot(x,y,'-') >> ind =3D ind + 2 >> > > You could try something like: > > colors =3D ["r", "g", "b", "k", "y", "c", "m"] # And Others > > counter =3D 0 > > while ind < 18: > Y =3D take(X,(0,ind), 1) > x =3D Y[:,0] > y =3D Y[:,1] > plot(x,y,colors[counter] + '-') > counter =3D counter + 1 > ind =3D ind + 2 > > > Sorry, don't know for the second one... > > HTH. > > Andrea. > --=20 DI Dr. Werner Pessenhofer CPA - Computer Process Automation Pl=FCddemanngasse 33 8010 Graz Tel.: +43 (0) 676 346 70 08 FAX: +43 (0) 316 873 8772 ```

 Re: [Matplotlib-users] Plotting of multiple spectras From: Dr. Werner Pessenhofer - 2005-04-27 13:12:55 ```Thanks for the idea ! Meanwhile I've improved it somewhat: ylen =3D shape(Ximport)[1] colors =3D ["r", "g", "b", "k", "y", "c", "m"] # And Others counter =3D 0 ind =3D 1 for ind in range(1, ylen, 2): Y =3D take(X,(0,ind), 1) x =3D Y[:,0] y =3D Y[:,1] plot(x,y,colors[counter]+'-') if counter < 5: counter =3D counter + 1 else: counter =3D 0 If my thoughts are right, this would return to beginning of colors if the= =20 last one is arrived. Regards Werner On Wed, 27 Apr 2005 14:50:49 +0200, wrote: > Hello Werner, > >> The first problem is, that all curves have the same color. Is there a > >> possibility to "rotate" the colors in the loop ? > >> while ind < 18: >> Y =3D take(X,(0,ind), 1) >> x =3D Y[:,0] >> y =3D Y[:,1] >> plot(x,y,'-') >> ind =3D ind + 2 >> > > You could try something like: > > colors =3D ["r", "g", "b", "k", "y", "c", "m"] # And Others > > counter =3D 0 > > while ind < 18: > Y =3D take(X,(0,ind), 1) > x =3D Y[:,0] > y =3D Y[:,1] > plot(x,y,colors[counter] + '-') > counter =3D counter + 1 > ind =3D ind + 2 > > > Sorry, don't know for the second one... > > HTH. > > Andrea. > --=20 DI Dr. Werner Pessenhofer CPA - Computer Process Automation Pl=FCddemanngasse 33 8010 Graz Tel.: +43 (0) 676 346 70 08 FAX: +43 (0) 316 873 8772 ```
 Re: [Matplotlib-users] Plotting of multiple spectras From: John Hunter - 2005-04-27 15:33:20 ```>>>>> "Werner" == Werner Pessenhofer writes: Werner> If my thoughts are right, this would return to beginning Werner> of colors if the last one is arrived. The code in the original example already does that plot(x,y,'-'+colors[ind % len(colors)]) Note that ind % len(colors) never reaches len(colors), but cycles >>> N = 5 >>> for i in range(12): print i%N ... 0 1 2 3 4 0 1 2 3 4 0 JDH ```