aboutsummaryrefslogtreecommitdiffstats
path: root/examples/graphs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/graphs')
-rw-r--r--examples/graphs/axis.jl1
-rw-r--r--examples/graphs/change.jl33
-rw-r--r--examples/graphs/join.dat30
-rw-r--r--examples/graphs/join.jl47
4 files changed, 111 insertions, 0 deletions
diff --git a/examples/graphs/axis.jl b/examples/graphs/axis.jl
index cc699bb..915414e 100644
--- a/examples/graphs/axis.jl
+++ b/examples/graphs/axis.jl
@@ -1,4 +1,5 @@
+# Original Python:
#from pyx import *
#
#g = graph.graphxy(width=8,
diff --git a/examples/graphs/change.jl b/examples/graphs/change.jl
new file mode 100644
index 0000000..9034dc5
--- /dev/null
+++ b/examples/graphs/change.jl
@@ -0,0 +1,33 @@
+
+# Original Python:
+# from pyx import *
+#
+# g = graph.graphxy(width=8,
+# x=graph.axis.linear(min=0, max=2),
+# y=graph.axis.linear(min=0, max=2),
+# key=graph.key.key(pos="br", dist=0.1))
+# g.plot([graph.data.function("x(y)=y**4", title=r"$x = y^4$"),
+# graph.data.function("x(y)=y**2", title=r"$x = y^2$"),
+# graph.data.function("x(y)=y", title=r"$x = y$"),
+# graph.data.function("y(x)=x**2", title=r"$y = x^2$"),
+# graph.data.function("y(x)=x**4", title=r"$y = x^4$")],
+# [graph.style.line([color.gradient.Rainbow])])
+# g.writeEPSfile("change")
+# g.writePDFfile("change")
+# g.writeSVGfile("change")
+
+using PyX
+using LaTeXStrings
+
+g = graph.graphxy(width=8,
+ x=graph_axis.linear(min=0, max=2),
+ y=graph_axis.linear(min=0, max=2),
+ key=graph_key.key(pos="br", dist=0.1))
+plot(g, [graph_data_function("x(y)=y**4", title=L"$x = y^4$"),
+ graph_data_function("x(y)=y**2", title=L"$x = y^2$"),
+ graph_data_function("x(y)=y", title=L"$x = y$"),
+ graph_data_function("y(x)=x**2", title=L"$y = x^2$"),
+ graph_data_function("y(x)=x**4", title=L"$y = x^4$")],
+ [graph_style.line([color_gradient.Rainbow])])
+writeEPSfile(g, "change")
+writePDFfile(g, "change")
diff --git a/examples/graphs/join.dat b/examples/graphs/join.dat
new file mode 100644
index 0000000..1bdc1b9
--- /dev/null
+++ b/examples/graphs/join.dat
@@ -0,0 +1,30 @@
+0 -0.0416523 0.00370405 -0.0120944
+0.0344828 0.0758855 0.144363 0.203587
+0.0689655 0.105887 0.259478 0.3624
+0.103448 0.170788 0.360286 0.542374
+0.137931 0.20317 0.407522 0.704534
+0.172414 0.311803 0.481457 0.80502
+0.206897 0.338232 0.594614 0.821449
+0.241379 0.302589 0.612485 0.906532
+0.275862 0.335894 0.59561 0.898951
+0.310345 0.286523 0.537869 0.842022
+0.344828 0.241982 0.471199 0.78992
+0.37931 0.201726 0.391884 0.645232
+0.413793 0.115665 0.282956 0.499897
+0.448276 0.126654 0.176257 0.328663
+0.482759 0.066533 0.0198417 0.110219
+0.517241 -0.0331831 -0.0761098 -0.141317
+0.551724 -0.0927296 -0.219183 -0.241559
+0.586207 -0.179708 -0.270902 -0.460771
+0.62069 -0.162048 -0.456294 -0.575559
+0.655172 -0.20805 -0.530463 -0.780346
+0.689655 -0.242298 -0.528865 -0.822735
+0.724138 -0.315267 -0.588264 -0.905236
+0.758621 -0.305853 -0.643168 -0.903536
+0.793103 -0.291477 -0.592055 -0.857436
+0.827586 -0.289402 -0.484567 -0.76292
+0.862069 -0.270358 -0.430461 -0.675236
+0.896552 -0.231194 -0.328504 -0.512663
+0.931034 -0.17519 -0.221731 -0.330941
+0.965517 -0.0567209 -0.0880629 -0.200636
+1 0.0449826 -0.0469508 0.0426738
diff --git a/examples/graphs/join.jl b/examples/graphs/join.jl
new file mode 100644
index 0000000..f33e498
--- /dev/null
+++ b/examples/graphs/join.jl
@@ -0,0 +1,47 @@
+
+# Original Python:
+# from pyx import *
+#
+# g = graph.graphxy(width=8, key=graph.key.key())
+#
+# As = [0.3, 0.6, 0.9]
+#
+# d = [graph.data.join([graph.data.function("y_a(x_a)=A*sin(2*pi*x_a)", context=dict(A=A)),
+# graph.data.file("join.dat", x_b=1, y_b=i+2)],
+# title=r"$A=%g$" % A)
+# for i, A in enumerate(As)]
+#
+# attrs = [color.gradient.RedBlue]
+#
+# g.plot(d,
+# [graph.style.pos(usenames=dict(x="x_a", y="y_a")),
+# graph.style.line(attrs),
+# graph.style.pos(usenames=dict(x="x_b", y="y_b")),
+# graph.style.symbol(graph.style.symbol.changesquare, symbolattrs=attrs, size=0.1)])
+#
+# g.writeEPSfile()
+# g.writePDFfile()
+# g.writeSVGfile()
+
+using PyX
+
+g = graph.graphxy(width=8, key=graph_key.key())
+
+As = [0.3, 0.6, 0.9]
+
+d = [graph_data.join([graph_data_function("y_a(x_a)=A*sin(2*pi*x_a)", context=Dict("A"=>A)),
+ graph_data.file("examples/graphs/join.dat", x_b=1, y_b=i+1)],
+ title=latexstring("\$A=$A\$"))
+ for (i, A) in enumerate(As)]
+
+attrs = [color_gradient.RedBlue]
+
+plot(g, d,
+ [graph_style.pos(usenames=Dict("x"=>"x_a", "y"=>"y_a")),
+ graph_style.line(attrs),
+ graph_style.pos(usenames=Dict("x"=>"x_b", "y"=>"y_b")),
+ graph_style.symbol(graph_style_symbol.changesquare, symbolattrs=attrs, size=0.1)])
+
+writeEPSfile(g, "join")
+writePDFfile(g, "join")
+