warn for text as path being impossible without a font
[PyX.git] / design / selfinter2.py
bloba7c4af36a0a745a75212905107f096a6695c2219
1 #!/usr/bin/env python3
2 import sys;sys.path.insert(0, "..")
3 from math import *
4 from pyx import *
5 # File for invalid parametrisations of Bezier curves
6 # Draws a sketch of the areas where invalid params are to be expected
8 xmin, xmax = -2, 5
9 ymin, ymax = -xmax, 2
11 g = graph.graphxy(width=10,
12 x=graph.axis.lin(title=r"$\Delta x$", min=xmin, max=xmax),
13 y=graph.axis.lin(title=r"$\Delta y$", min=ymin, max=ymax),
14 key=graph.key.key(pos="tr"),
16 g.plot(graph.data.function("y(x)=-1", title=None), [graph.style.line([style.linestyle.dotted])])
17 d1 = g.plot(graph.data.function("x(y)=(-1-2*y-sqrt((1+2*y)**2+3))/3.0", title=r"cusp ($-$)"), [graph.style.line()])
18 d2 = g.plot(graph.data.function("x(y)=(-1-2*y+sqrt((1+2*y)**2+3))/3.0", title=r"cusp ($+$)", max=-1), [graph.style.line([color.rgb.red])])
19 d3 = g.plot(graph.data.function("x(y)=1.0/(3.0*(y+1))", title=r"passes through $(0,0)$", max=-1), [graph.style.line([color.rgb.green])])
20 d4 = g.plot(graph.data.function("x(y)=(1+y**3)/(3.0*(1+y))", title=r"passes through $(1,0)$", max=-1), [graph.style.line([color.rgb.blue])])
21 g.doplot()
23 p = d1.path << d3.path.reversed()
24 p.append(path.closepath())
25 g.layers["filldata"].fill(p, [color.gray(0.8)])
27 p = d2.path << d4.path.reversed()
28 p.append(path.closepath())
29 g.layers["filldata"].fill(p, [color.gray(0.8)])
31 g.writePDFfile()