Hi,
It would be great if someone could please answer my questions about bar
graphs. These are coming from a total newbie to Pyx, so sorry if the answers
are obvious.
First question - How do you get the font in the axes titles on a bar graph
to be the same as the the text in the axes labels and the key. It looks like
it is not latex, and my symbols that are meant to show up in latex are not
formatted properly.
This is what my data file looks like:
NMR.dat;
#site #CLD33 #CLD34 #CLD35
\bf{\ce{CH3}} 15 14 14
\bf{\ce{NCH3}} 27 27 26
\bf{\ce{CH2}} 29 27 27
\bf{\ce{CH}} 1 1 2
\bf{\ce{C6H5}} 28 31 31
This is what I put in:
from pyx import*
text.set(mode="latex")
text.preamble("\usepackage{wasysym}")
text.preamble("\usepackage[version=3]{mhchem}")
mypainter = graph.axis.painter.bar(nameattrs=[trafo.rotate(45),
text.halign.right],
innerticklength=0.1)
myaxis = graph.axis.nestedbar(painter=mypainter, title="\ce{2H}
Environment")
g = graph.graphxy(width=8, x=myaxis, y=graph.axis.linear(min=0, max=45,
title="\ce{2H}"), key=graph.key.key(pos="tl"))
g.plot([graph.data.file("NMR.dat", xname="$1, 0", y=2, title="CLD33"),
graph.data.file("NMR.dat", xname="$1, 1", y=3, title="CLD34"),
graph.data.file("NMR.dat", xname="$1, 2", y=4, title="CLD35")],
[graph.style.bar()])
g.writePDFfile("NMRgraph")
The \ce{2H} should come up as an H with a superscript 2 before it, but it
just comes out as 2H (i.e the 2 is not superscript).
>From what I have read in the documentation for pyx I cannot figure out how
to fix this.
Second question - Is there any way that I can make the width of the bars
consistent between graphs. In the graph I am trying to make I am comparing
two graphs inserted on the same canvas. I would like the two graphs to have
the same width bars, but one graph is a nested bar graph with 3 data sets on
it, and the other graph only has one data set on it. So the graph with the
one data set has wider bars than the one with 3.
I use the data file from the first question, plus this one;
NMR2.dat;
#site #CLDE2
\bf{\ce{CH3}} 15
\bf{\ce{NCH3}} 18
\bf{\ce{CH(OH)}} 37
\bf{\ce{CH}} 0
\bf{\ce{C6H5}} 30
And in Pyx I enter;
from pyx import*
text.set(mode="latex")
text.preamble("\usepackage{wasysym}")
text.preamble("\usepackage[version=3]{mhchem}")
c = canvas.canvas()
mypainter = graph.axis.painter.bar(nameattrs=[trafo.rotate(45),
text.halign.right],
innerticklength=0.1, titleattrs=[])
myaxis = graph.axis.nestedbar(painter=mypainter, title=("\ce{2H}
Environment"))
g1 = graph.graphxy(width=8, x=myaxis, y=graph.axis.linear(min=0, max=45,
title="\ce{2H}"), key=graph.key.key(pos="tl"))
g1.plot([graph.data.file("NMR.dat", xname="$1, 0", y=2, title="CLD33"),
graph.data.file("NMR.dat", xname="$1, 1", y=3, title="CLD34"),
graph.data.file("NMR.dat", xname="$1, 2", y=4, title="CLD35")],
[graph.style.bar()])
c.insert(g1)
myaxis2 = graph.axis.bar(painter=mypainter)
g2 = graph.graphxy(width=8, x=myaxis2, y=graph.axis.linear(min=0, max=45),
key=graph.key.key(pos="tl"), xpos=g1.xpos+g1.width+1)
g2.plot([graph.data.file("NMR2.dat", xname=1, y=2, title="CLDE2")],
[graph.style.bar()])
c.insert(g2)
c.writePDFfile("NMRcomparegraph")
Thanks,
Gabby
-------------------------------------------------------------------------
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