From 439655aaa40568acd0b4f536e67f6b90031ee147 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 21 Feb 2016 14:09:55 -0800 Subject: add examples (all ports from PyX 0.14.1) --- examples/graphs/axis.jl | 20 ++++++++++++++++++++ examples/graphs/function.jl | 16 ++++++++++++++++ examples/graphs/lissajous.jl | 17 +++++++++++++++++ examples/graphs/minimal.dat | 6 ++++++ examples/graphs/minimal.jl | 16 ++++++++++++++++ examples/graphs/points.jl | 23 +++++++++++++++++++++++ 6 files changed, 98 insertions(+) create mode 100644 examples/graphs/axis.jl create mode 100644 examples/graphs/function.jl create mode 100644 examples/graphs/lissajous.jl create mode 100644 examples/graphs/minimal.dat create mode 100644 examples/graphs/minimal.jl create mode 100644 examples/graphs/points.jl (limited to 'examples/graphs') 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") -- cgit v1.2.3