aboutsummaryrefslogtreecommitdiffstats
path: root/examples/graphs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/graphs')
-rw-r--r--examples/graphs/axis.jl20
-rw-r--r--examples/graphs/function.jl16
-rw-r--r--examples/graphs/lissajous.jl17
-rw-r--r--examples/graphs/minimal.dat6
-rw-r--r--examples/graphs/minimal.jl16
-rw-r--r--examples/graphs/points.jl23
6 files changed, 98 insertions, 0 deletions
diff --git a/examples/graphs/axis.jl b/examples/graphs/axis.jl
new file mode 100644
index 0000000..cc699bb
--- /dev/null
+++ b/examples/graphs/axis.jl
@@ -0,0 +1,20 @@
+
+#from pyx import *
+#
+#g = graph.graphxy(width=8,
+# x=graph.axis.log(min=1e-1, max=1e4, title=r"$x$-axis"),
+# y=graph.axis.lin(max=5, title=r"$y$-axis"))
+#g.plot(graph.data.function("y(x)=tan(log(1/x))**2"))
+#g.writeEPSfile("axis")
+#g.writePDFfile("axis")
+#g.writeSVGfile("axis")
+
+using PyX
+using LaTeXStrings
+
+g = graph.graphxy(width=8,
+ x=graph_axis.log(min=1e-1, max=1e4, title=L"$x$-axis"),
+ y=graph_axis.lin(max=5, title=L"$y$-axis"))
+plot(g, graph_data_function("y(x)=tan(log(1/x))**2"))
+writeEPSfile(g, "axis")
+writePDFfile(g, "axis")
diff --git a/examples/graphs/function.jl b/examples/graphs/function.jl
new file mode 100644
index 0000000..e995855
--- /dev/null
+++ b/examples/graphs/function.jl
@@ -0,0 +1,16 @@
+
+# Original Python:
+# from pyx import *
+#
+# g = graph.graphxy(width=8)
+# g.plot(graph.data.function("y(x)=sin(x)/x", min=-15, max=15))
+# g.writeEPSfile("function")
+# g.writePDFfile("function")
+# g.writeSVGfile("function")
+
+using PyX
+
+g = graph.graphxy(width=8)
+plot(g, graph_data_function("y(x)=sin(x)/x", min=-15, max=15))
+writeEPSfile(g, "function")
+writePDFfile(g, "function")
diff --git a/examples/graphs/lissajous.jl b/examples/graphs/lissajous.jl
new file mode 100644
index 0000000..e66ca04
--- /dev/null
+++ b/examples/graphs/lissajous.jl
@@ -0,0 +1,17 @@
+
+# Original Python:
+# from math import pi
+# from pyx import *
+#
+# g = graph.graphxy(width=8)
+# g.plot(graph.data.paramfunction("k", 0, 2*pi, "x, y = sin(2*k), cos(3*k)"))
+# g.writeEPSfile("lissajous")
+# g.writePDFfile("lissajous")
+# g.writeSVGfile("lissajous")
+
+using PyX
+
+g = graph.graphxy(width=8)
+plot(g, graph_data.paramfunction("k", 0, 2*pi, "x, y = sin(2*k), cos(3*k)"))
+writeEPSfile(g, "lissajous")
+writePDFfile(g, "lissajous")
diff --git a/examples/graphs/minimal.dat b/examples/graphs/minimal.dat
new file mode 100644
index 0000000..7108052
--- /dev/null
+++ b/examples/graphs/minimal.dat
@@ -0,0 +1,6 @@
+1 2
+2 3
+3 8
+4 13
+5 18
+6 21
diff --git a/examples/graphs/minimal.jl b/examples/graphs/minimal.jl
new file mode 100644
index 0000000..fe4d272
--- /dev/null
+++ b/examples/graphs/minimal.jl
@@ -0,0 +1,16 @@
+
+# Original Python:
+# from pyx import *
+#
+# g = graph.graphxy(width=8)
+# g.plot(graph.data.file("minimal.dat", x=1, y=2))
+# g.writeEPSfile("minimal")
+# g.writePDFfile("minimal")
+# g.writeSVGfile("minimal")
+
+using PyX
+
+g = graph.graphxy(width=8)
+plot(g, graph_data.file("examples/graphs/minimal.dat", x=1, y=2))
+writeEPSfile(g, "minimal")
+writePDFfile(g, "minimal")
diff --git a/examples/graphs/points.jl b/examples/graphs/points.jl
new file mode 100644
index 0000000..9136ee0
--- /dev/null
+++ b/examples/graphs/points.jl
@@ -0,0 +1,23 @@
+
+# Original Python:
+# suggested by Chris Spencer
+# from pyx import *
+#
+# g = graph.graphxy(width=8)
+# # either provide lists of the individual coordinates
+# g.plot(graph.data.values(x=list(range(10)), y=list(range(10))))
+# # or provide one list containing the whole points
+# g.plot(graph.data.points(list(zip(range(10), range(10))), x=1, y=2))
+# g.writeEPSfile("points")
+# g.writePDFfile("points")
+# g.writeSVGfile("points")
+
+using PyX
+
+g = graph.graphxy(width=8)
+plot(g, graph_data.values(x=1:10, y=1:10))
+# XXX: x, y syntax in Python3 version only
+# XXX: also other errors
+#plot(g, graph_data.points([[i i] for i in 1:10], 1:10), x=1, y=2)
+writeEPSfile(g, "points")
+writePDFfile(g, "points")