Hi,
On 30.06.05, vapor direku wrote:
> How can I color different bands with different colors? E.g.
>
> for band in Somewhere
> g.plot(graph.data.list(band, x=1, y=2),
> [graph.style.line([style.linewidth.Thin,
> style.linestyle.solid ])] )
>
> a) how can I use the color palettes to color different bands according to
> their order
> b) how can I color them to my will, for example: 1black, 2red, 3green,
> 4blue...
there are different solutions to that. The first would be to
explicitly set a color:
from pyx import *
g = graph.graphxy(width=10)
g.plot(graph.data.function("y=sin(x)", min=0, max=10),
[graph.style.line([style.linewidth.Thin,
style.linestyle.solid,
color.gray.black])])
g.plot(graph.data.function("y=cos(x)", min=0, max=10),
[graph.style.line([style.linewidth.Thin,
style.linestyle.solid,
color.rgb.red])])
g.writeEPSfile("colors")
But the idea is, that whenever you use the same set of styles in
several plot commands or put several data into a single plot command,
the styles are "changing" their attribues.
from pyx import *
g = graph.graphxy(width=10)
g.plot([graph.data.function("y=sin(x)", min=0, max=10),
graph.data.function("y=cos(x)", min=0, max=10)])
g.writeEPSfile("colors")
That's how the linestyle is changed here (its due to the default
styles used by for graph.data.function instances). Now, you can do
such a thing yourself:
from pyx import *
g = graph.graphxy(width=10)
g.plot([graph.data.function("y=sin(x)", min=0, max=10),
graph.data.function("y=cos(x)", min=0, max=10)],
[graph.style.line([style.linestyle.clear,
color.palette.Rainbow])])
g.writeEPSfile("colors")
(Instead of setting the linestyle, I can remove the default linestyle
setting of graph.style.line by style.linestyle.clear.)
To set up a changeable style yourself, you can do:
from pyx import *
g = graph.graphxy(width=10)
g.plot([graph.data.function("y=sin(x)", min=0, max=10),
graph.data.function("y=cos(x)", min=0, max=10)],
[graph.style.line([style.linestyle.clear,
attr.changelist([color.gray.black,
color.rgb.red])])])
g.writeEPSfile("colors")
Of course you can store those changeable attribues or graph styles
etc. and use them again and again. And I do know, that we're currently
lacking some documentation about the attribute features ... :(
André

by _ _ _ Dr. André Wobst
/ \ \ / ) wobsta@..., http://www.wobsta.de/
/ _ \ \/\/ / PyX  High quality PostScript figures with Python & TeX
(_/ \_)_/\_/ visit http://pyx.sourceforge.net/
