def testDec(self): ticks = [tick((1, 4), labellevel=0), tick((2, 4), labellevel=0)] decimal().labels(ticks) self.assertEqual([t.label for t in ticks], ["0.25", "0.5"]) ticks = [tick((1, 4), labellevel=0), tick((2, 4), labellevel=0)] decimal(equalprecision=1).labels(ticks) self.assertEqual([t.label for t in ticks], ["0.25", "0.50"]) ticks = [tick((1, 17), labellevel=0), tick((17, 17), labellevel=0)] decimal().labels(ticks) self.assertEqual([t.label for t in ticks], [r"0.\overline{0588235294117647}", "1"]) ticks = [ tick((1, 10000000), labellevel=0), tick((1, 100000000), labellevel=0), tick((1, 1000000000), labellevel=0) ] decimal(thousandthpartsep=",").labels(ticks) self.assertEqual([t.label for t in ticks], ["0.000,000,1", "0.000,000,01", "0.000,000,001"]) ticks = [ tick((1000000, 1), labellevel=0), tick((10000000, 1), labellevel=0), tick((100000000, 1), labellevel=0) ] decimal(thousandsep=",").labels(ticks) self.assertEqual([t.label for t in ticks], ["1,000,000", "10,000,000", "100,000,000"])
def testDefault(self): ticks = [ tick((0, 10), labellevel=0), tick((1, 10), labellevel=0), tick((1, 1), labellevel=0), tick((10, 1), labellevel=0) ] default().labels(ticks) self.assertEqual([tex_expr(t.label) for t in ticks], ["0", "0.1", "1", "10"]) ticks = [ tick((0, 10), labellevel=0), tick((1, 10), labellevel=0), tick((1, 1), labellevel=0), tick((10000, 1), labellevel=0) ] default(minexponent=1, skipmantissaunity=skipmantissaunity.never, uniformexponent=False).labels(ticks) self.assertEqual([tex_expr(t.label) for t in ticks], [r"0", r"1\cdot{}10^{-1}", r"1", r"1\cdot{}10^{4}"]) ticks = [ tick((0, 10), labellevel=0), tick((1, 10), labellevel=0), tick((1, 1), labellevel=0), tick((10000, 1), labellevel=0) ] default(minexponent=2, uniformexponent=False).labels(ticks) self.assertEqual([tex_expr(t.label) for t in ticks], ["0", "0.1", "1", r"10^{4}"]) ticks = [ tick((-1, 10), labellevel=0), tick((1, 1), labellevel=0), tick((10, 1), labellevel=0) ] default(minexponent=0).labels(ticks) self.assertEqual([tex_expr(t.label) for t in ticks], [r"-10^{-1}", r"10^{0}", r"10^{1}"]) ticks = [ tick((0, 1), labellevel=0), tick((1, -10), labellevel=0), tick((15, 100), labellevel=0) ] default(minnegexponent=0, mantissatexter=decimal(equalprecision=True)).labels(ticks) self.assertEqual( [tex_expr(t.label) for t in ticks], [r"0.0\cdot{}10^{0}", r"-1.0\cdot{}10^{-1}", r"1.5\cdot{}10^{-1}"]) ticks = [ tick((0, 1), labellevel=0), tick((1, -10), labellevel=0), tick((15, 100), labellevel=0) ] default(minnegexponent=1, mantissatexter=decimal(equalprecision=True)).labels(ticks) self.assertEqual([tex_expr(t.label) for t in ticks], [r"0.0", r"-1.0\cdot{}10^{-1}", r"1.5\cdot{}10^{-1}"])
def testExp(self): ticks = [tick((-1, 10), labellevel=0), tick((1, 1), labellevel=0), tick((10, 1), labellevel=0)] exponential().labels(ticks) self.assertEqual([t.label for t in ticks], [r"{-10^{-1}}", r"{10^{0}}", r"{10^{1}}"]) ticks = [tick((0, 1), labellevel=0), tick((1, -10), labellevel=0), tick((15, 100), labellevel=0)] exponential(mantissatexter=decimal(equalprecision=1)).labels(ticks) self.assertEqual([t.label for t in ticks], [r"{0.0}", r"{{-1.0}\cdot10^{-1}}", r"{{1.5}\cdot10^{-1}}"])
def testDec(self): ticks = [tick((1, 4), labellevel=0), tick((2, 4), labellevel=0)] decimal().labels(ticks) self.assertEqual([t.label for t in ticks], ["0.25", "0.5"]) ticks = [tick((1, 4), labellevel=0), tick((2, 4), labellevel=0)] decimal(equalprecision=1).labels(ticks) self.assertEqual([t.label for t in ticks], ["0.25", "0.50"]) ticks = [tick((1, 17), labellevel=0), tick((17, 17), labellevel=0)] decimal().labels(ticks) self.assertEqual([t.label for t in ticks], [r"0.\overline{0588235294117647}", "1"]) ticks = [tick((1, 10000000), labellevel=0), tick((1, 100000000), labellevel=0), tick((1, 1000000000), labellevel=0)] decimal(thousandthpartsep=",").labels(ticks) self.assertEqual([t.label for t in ticks], ["0.000,000,1", "0.000,000,01", "0.000,000,001"]) ticks = [tick((1000000, 1), labellevel=0), tick((10000000, 1), labellevel=0), tick((100000000, 1), labellevel=0)] decimal(thousandsep=",").labels(ticks) self.assertEqual([t.label for t in ticks], ["1,000,000", "10,000,000", "100,000,000"])
from pyxcandy import read_dat, ssdata, ssplot text.set(cls=text.LatexRunner, texenc='utf-8') text.preamble(r'\usepackage[utf8]{inputenc}') text.preamble(r'\usepackage{textgreek}') text.preamble(r'\usepackage{fixltx2e}') text.preamble(r'\usepackage{libertine}') text.preamble(r'\renewcommand{\familydefault}{\sfdefault}') text.preamble(r'\usepackage{sansmath}') g = graph.graphxy( width=5.0, height=1.2, x=axis.linear(min=1, max=269, texter=texter.decimal(labelattrs=[text.clearmathmode]), title="TN residue"), y=axis.linear(min=0.0, parter=parter.linear(tickdists=[4.0, 2.0]), max=8.0, texter=texter.decimal(labelattrs=[text.clearmathmode]), title=r"RMSF ± std (Å)")) resid, rmsf_mean, rmsf_std = read_dat("rmsf.dat", [int, float, float]) g.plot(data.values(x=resid, y=rmsf_mean), [graph.style.line()]) ss = [line.strip() for line in open("ss.dat")] ssplot(g, ssdata(ss))