Hi Carl,
On 25.07.06, Carl Bolduc wrote:
> I'm using Pyx to plot this file:
> ________________________________________________________
> SAGE Q_RT-PCR Genes
> 9.61 22.36 Adiponectin
> 5.73 -19.16 Acyl-Coenzyme A dehydrogenase, very long chain
> -8.46 -21.25 1-acylglycerol-3-phosphate O-acyltransferase 2
> -10.68 -26.45 Fatty acid synthase
> 8.53 23.44 Lipoprotein lipase
> 9.39 23.77 Cell death-inducing DFFA-like effector c
> 5 20.65 Angiotensinogen
> 7.73 23.93 Neuronatin
> ________________________________________________________
Let me first change this data file to become:
--------------------------------------
#SAGE Q_RT-PCR Genes
9.61 22.36 Adiponectin
5.73 -19.16 "Acyl-Coenzyme A dehydrogenase, very long chain"
-8.46 -21.25 "1-acylglycerol-3-phosphate O-acyltransferase 2"
-10.68 -26.45 "Fatty acid synthase"
8.53 23.44 "Lipoprotein lipase"
9.39 23.77 "Cell death-inducing DFFA-like effector c"
5 20.65 Angiotensinogen
7.73 23.93 Neuronatin
--------------------------------------
By that the third column will properly contain the full strings. (You
can always ass the double quotes, but when having spaces you'll need
them. Or you could read/provide the data yourself ...)
> My actual script looks like this:
> ________________________________________________________
> from pyx import *
>
> g = graph.graphxy(width=8,
> x=graph.axis.lin(min=-15, max=15, title="SAGE"),
> y=graph.axis.lin(min=-30, max=30, title="RT-PCR"),
> )
>
> g.plot(graph.data.file("explevels.dat", x=1, y=2))
> g.writeEPSfile("minimal")
> g.writePDFfile("minimal")
> ________________________________________________________
>
> I would like to add a legend for each of the point. So each point should
> have a different shape and/or color and the legend should correspond to the
> 3rd column of the input file (Genes).
>
> How should I proceed?
At first you might consider to label the dots itself. This might be a
solution in certain cases. However, your case doesn't look well.
Anyway, the corresponding code would look like:
------------------------------------
from pyx import *
g = graph.graphxy(width=8,
x=graph.axis.lin(min=-15, max=15, title="SAGE"),
y=graph.axis.lin(min=-30, max=30, title="RT-PCR"),
)
g.plot(graph.data.file("explevels.dat", x=1, y=2, text=3),
[graph.style.symbol(), graph.style.text()])
g.writeEPSfile("minimal")
------------------------------------
But back to what you really want: Unfortunately due to some missing
features in the graph key system, we currently can have a single graph
key item per data set only (but this is already on my todo list). On
the other hand you want to alter the symbols as well. You could do
this by an own graph style. Or by using a set of data instances and
the usual symbol style. So lets try this, since it also solves the
graph key problem:
------------------------------------
from pyx import *
d = graph.data.file("explevels.dat", x=1, y=2, text=3)
ds = [graph.data.list([(x, y)], x=1, y=2, title=text)
for x, y, text in zip(d.columns['x'], d.columns['y'], d.columns['text'])]
g = graph.graphxy(width=8, key=graph.key.key(),
x=graph.axis.lin(min=-15, max=15, title="SAGE"),
y=graph.axis.lin(min=-30, max=30, title="RT-PCR"),
)
g.plot(ds)
g.writeEPSfile("minimal")
------------------------------------
(You may want to add a list of symbols. IIRC Arnd Bäcker wrote quite a
nice set of symbols. See
http://www.physik.tu-dresden.de/~baecker/python/pyxgraph.html ...
maybe you can up some of the symbols code. And we may add some to the
PyX core, but that's a different story.)
So the code above may work for you for the moment. Beside that I
promise to add some functionality to the graph keys to allow for
several key items per data+style instance (i.e. plotitem instance).
We'll need that for other styles as well (like the changebar) and we
want to at least be able to hide that in some proper graph styles ...
HTH,
André
--
by _ _ _ Dr. André Wobst
/ \ \ / ) [EMAIL PROTECTED], http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user