From bc0b68c6650e23b054aa5f751c5d21a8c2266866 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Wobst?= Date: Tue, 19 Oct 2004 13:46:56 +0000 Subject: [PATCH] - adjustments to the new path + graph data and style handling git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@1884 069f4177-920e-0410-937b-c2a4a81bcd90 --- examples/circles.py | 8 ++++---- examples/graphs/bar.py | 9 +++++---- examples/graphs/integral.py | 2 +- examples/graphs/manyaxes.py | 2 +- examples/graphs/partialfill.py | 8 ++++---- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/examples/circles.py b/examples/circles.py index 795e9844..09aaac16 100644 --- a/examples/circles.py +++ b/examples/circles.py @@ -4,12 +4,12 @@ circ1 = path.circle(0, 0, 1).normpath() # you don't really need normpath, circ2 = path.circle(1, 1, 1).normpath() # but its better to have it once # for those operations (circ1a, circ1b), (circ2a, circ2b) = circ1.intersect(circ2) -intersection = (circ2.split([circ2a, circ2b])[1] - << circ1.split([circ1b, circ1a])[1]) +intersection = (circ2.split([circ2b, circ2a])[1] + << circ1.split([circ1a, circ1b])[1]) intersection[-1].close() -union = (circ1.split([circ1b, circ1a])[0] - << circ2.split([circ2a, circ2b])[0]) +union = (circ1.split([circ1a, circ1b])[0] + << circ2.split([circ2b, circ2a])[0]) union[-1].close() c = canvas.canvas() diff --git a/examples/graphs/bar.py b/examples/graphs/bar.py index 719bd6ef..ab6ed039 100644 --- a/examples/graphs/bar.py +++ b/examples/graphs/bar.py @@ -2,19 +2,20 @@ from pyx import * # bar.dat looks like: from pyx.graph import axis # #month min max # January -5 1 # Feburary -4 3 -# we prepare some stuff first ... + +# we prepare some stuff first bap = axis.painter.bar # just an abbreviation a1 = axis.bar(painter=bap(nameattrs=None)) # for single bars a2 = axis.bar(painter=bap(nameattrs=[trafo.rotate(45), text.halign.right], innerticklength=0.2), subaxis=axis.bar(dist=0)) # for several bars -nofirst = [attr.changelist([None, color.rgb.green])] # special draw attrs c = canvas.canvas() # we draw several plots, thus we create a main canvas g = c.insert(graph.graphxy(ypos=4.5, width=8, height=4, x=a1)) -g.plot(graph.data.file("bar.dat", xname=1, y=2, ystack1=3), - [graph.style.bar(barattrs=nofirst)]) +g.plot(graph.data.file("bar.dat", xname=1, y=2, stack=3), + [graph.style.stackedbarpos("stack"), + graph.style.bar(barattrs=[color.rgb.green])]) g2 = c.insert(graph.graphxy(width=8, x=a2, height=4)) g2.plot([graph.data.file("bar.dat", xname=1, y=2), graph.data.file("bar.dat", xname=1, y=3)], diff --git a/examples/graphs/integral.py b/examples/graphs/integral.py index 0b9be901..4653beab 100644 --- a/examples/graphs/integral.py +++ b/examples/graphs/integral.py @@ -13,7 +13,7 @@ g = graph.graphxy(width=8, x2=None, y2=None, y=graph.axis.linear(title="$y$", parter=None, painter=p)) d = g.plot(graph.data.function("y=(x-3)*(x-5)*(x-7)")) g.finish() -p = d.styledata.path # the path is available after the graph is finished +p = d.path # the path is available after the graph is finished pa = g.xgridpath(a) pb = g.xgridpath(b) diff --git a/examples/graphs/manyaxes.py b/examples/graphs/manyaxes.py index a3a84180..50b582e7 100644 --- a/examples/graphs/manyaxes.py +++ b/examples/graphs/manyaxes.py @@ -11,7 +11,7 @@ g = graph.graphxy(width=8, y=graph.axis.log(), y2=graph.axis.lin(), d = [[i, math.exp(0.8*i+random.random())] for i in range(1,10)] f = lambda x, a: x*a -g.plot(graph.data.list(d, x=0, y=1)) +g.plot(graph.data.list(d, x=1, y=2)) g.plot(graph.data.function("y2=f(x, 1)", context=locals())) g.plot(graph.data.function("x=5+sin(2*pi*y3)")) diff --git a/examples/graphs/partialfill.py b/examples/graphs/partialfill.py index c042b0e2..eb7fc334 100644 --- a/examples/graphs/partialfill.py +++ b/examples/graphs/partialfill.py @@ -11,8 +11,8 @@ horiz = g.plot(graph.data.function("y=0.5*x", points=2)) g.finish() # convert paths to normpaths (for efficiency reasons only) -fline = fline.styledata.path.normpath() -horiz = horiz.styledata.path.normpath() +fline = fline.path.normpath() +horiz = horiz.path.normpath() # intersect the lines splith, splitf = horiz.intersect(fline) @@ -23,8 +23,8 @@ for i in range(0, len(splith)-2, 2): area = area.joined(horiz.split([splith[i+1], splith[i+2]])[1]) area = area.joined(fline.split([splitf[-2], splitf[-1]])[1]) area = area.joined(horiz.split([splith[-1]])[1]) -area.append(path.lineto(*g.vpos(1, 0))) -area.append(path.lineto(*g.vpos(0, 0))) +area[-1].append(path.normline(*(area[-1].end_pt() + g.vpos_pt(1, 0)))) +area[-1].append(path.normline(*(area[-1].end_pt() + g.vpos_pt(0, 0)))) area[-1].close() c = canvas.canvas() -- 2.11.4.GIT