From: Joerg L. <jo...@us...> - 2005-01-13 20:01:17
|
Hi Toan, On 13.01.05, Toan T Nguyen wrote: [ snip ] > Anyway, I try the color.palette.Rainbow for better colors but It gave a > ZeroDivisionError. Could you help again this time. Or is it a bug? > > Here is the program (the data for one plot are all in one line, x1 y1 x2 > y2 , different lines correspond to different plots, 14 plots in total): > > =================================== > from pyx import * > > g = graph.graphxy(width=8, key=graph.key.key(pos="br"), > x=graph.axis.log() > ) > > finfile = open('all.dat') > > for i in range(14): > data= finfile.readline().split() > > d = [] > for idx in range(7,93,4): > d.append([float(data[idx]),float(data[idx+2])]) > > mytitle = "$"+data[1]+"/"+data[2]+"$" > > g.plot(graph.data.list(d, x=1, y=2, title=mytitle), > [ graph.style.line( [style.linewidth.THIN,color.palette.Rainbow] ) ] > ) > > g.writeEPSfile('EvsG_75.eps') [ snip traceback ] The problem is that there is only one data set to be plotted and, thus, color.palette.Rainbow does not know which color to choose. At the moment, this leads to a ZeroDivisionError, which is probably not optimal. Maybe a reasonable choice would be the first color, i.e., the one with value=0. Anyway, to make your example work, just replace color.palette.Rainbow by an arbitrary color, e.g., color.rgb.red. Jörg |