Plotting of multiple spectras

Hi all,

I'm using matplotlib and Numeric since a few days ago, so I am not very sophisticated in using python :slight_smile:

I want to use matplotlib to print automatically several spectras from a file. This means, it takes the first column as x-value and the second, fourth, sixth .... column as y-value.

The script I wrote:

路路路

____________________________________________________

#!/usr/bin/python
#-*- coding: UTF-8 -*-

from pylab import *

X = load('Spektren-CuP-conv.dat',comments='#')

hold(True)

xlabel(r'$\rm{Wellenl\"ange / nm}$')
ylabel('Extinktion')
title('Spektren CuP')

ind = 1
while ind < 18:
聽聽聽聽聽Y = take(X,(0,ind), 1)
聽聽聽聽聽x = Y[:,0]
聽聽聽聽聽y = Y[:,1]
聽聽聽聽聽plot(x,y,'-')
聽聽聽聽聽ind = ind + 2

savefig("Spektren-CuP.ps",orientation="landscape")

show()
________________________________________________________

The first problem is, that all curves have the same color. Is there a possibility to "rotate" the colors in the loop ?

Second question:

With savefig("Spektren-CuP.ps",orientation="landscape"), the diagram do not fill the whole a4 page. I think, this is related to some configuration values, cause the resulting figure is not an a4 page but a BBox. Any hints where to change that ?

Regards

Werner

--
DI Dr. Werner Pessenhofer

CPA - Computer Process Automation
Pl眉ddemanngasse 33
8010 Graz
Tel.: +43 (0) 676 346 70 08
FAX: +43 (0) 316 873 8772

Hi Dr. Pessenhofer,

____________________________________________________

#!/usr/bin/python
#-*- coding: UTF-8 -*-

from pylab import *

X = load('Spektren-CuP-conv.dat',comments='#')

hold(True)

xlabel(r'\\rm\{Wellenl\\&quot;ange / nm\}')
ylabel('Extinktion')
title('Spektren CuP')

ind = 1
while ind < 18:
     Y = take(X,(0,ind), 1)
     x = Y[:,0]
     y = Y[:,1]
     plot(x,y,'-')
     ind = ind + 2

savefig("Spektren-CuP.ps",orientation="landscape")

show()
________________________________________________________

The first problem is, that all curves have the same color. Is there a
possibility to "rotate" the colors in the loop ?

You could change plot(x,y,'-') to plot(x,y). It will default to the '-'
linestyle, and matplotlib will cycle the colors for you. Also, the examples
include a script called line_styles.py with this suggestion:

路路路

On Wednesday 27 April 2005 4:12 am, Dr. Werner Pessenhofer wrote:

Second question:

With savefig("Spektren-CuP.ps",orientation="landscape"), the diagram do
not fill the whole a4 page. I think, this is related to some configuration
values, cause the resulting figure is not an a4 page but a BBox. Any hints
where to change that ?

Regards

Werner

--
Darren S. Dale

Bard Hall
Department of Materials Science and Engineering
Cornell University
Ithaca, NY. 14850

dd55@...163...

Hi Dr. Pessenhofer,

____________________________________________________

#!/usr/bin/python
#-*- coding: UTF-8 -*-

from pylab import *

X = load('Spektren-CuP-conv.dat',comments='#')

hold(True)

xlabel(r'\\rm\{Wellenl\\&quot;ange / nm\}')
ylabel('Extinktion')
title('Spektren CuP')

ind = 1
while ind < 18:
Y = take(X,(0,ind), 1)
x = Y[:,0]
y = Y[:,1]
plot(x,y,'-')
ind = ind + 2

savefig("Spektren-CuP.ps",orientation="landscape")

show()
________________________________________________________

The first problem is, that all curves have the same color. Is there a
possibility to "rotate" the colors in the loop ?

You could change plot(x,y,'-') to plot(x,y). It will default to the '-'
linestyle, and matplotlib will cycle the colors for you. Also, the examples
include a script called line_styles.py with this suggestion:

colors = ('b', 'g', 'r', 'c', 'm', 'y', 'k')
ind = 1
while ind < 18:
     Y = take(X,(0,ind), 1)
     x = Y[:,0]
     y = Y[:,1]
     plot(x,y,'-'+colors[ind % len(colors)])
     ind = ind + 2

Second question:

With savefig("Spektren-CuP.ps",orientation="landscape"), the diagram do
not fill the whole a4 page. I think, this is related to some configuration
values, cause the resulting figure is not an a4 page but a BBox. Any hints
where to change that ?

In your Spektren-CuP.ps, try adding "%%DocumentPaperSizes: A4" after the line
that says "%%Orientation: landscape", hopefully that can get you by while I
work on a real solution.

路路路

On Wednesday 27 April 2005 4:12 am, Dr. Werner Pessenhofer wrote:

--
Darren S. Dale

Bard Hall
Department of Materials Science and Engineering
Cornell University
Ithaca, NY. 14850

dd55@...163...