aboutsummaryrefslogtreecommitdiff
path: root/src/input/plotfile.input.pamphlet
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
committerdos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
commitab8cc85adde879fb963c94d15675783f2cf4b183 (patch)
treec202482327f474583b750b2c45dedfc4e4312b1d /src/input/plotfile.input.pamphlet
downloadopen-axiom-ab8cc85adde879fb963c94d15675783f2cf4b183.tar.gz
Initial population.
Diffstat (limited to 'src/input/plotfile.input.pamphlet')
-rw-r--r--src/input/plotfile.input.pamphlet84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/input/plotfile.input.pamphlet b/src/input/plotfile.input.pamphlet
new file mode 100644
index 00000000..e99d78a5
--- /dev/null
+++ b/src/input/plotfile.input.pamphlet
@@ -0,0 +1,84 @@
+\documentclass{article}
+\usepackage{axiom}
+\begin{document}
+\title{\$SPAD/src/input plotfile.input}
+\author{The Axiom Team}
+\maketitle
+\begin{abstract}
+\end{abstract}
+\eject
+\tableofcontents
+\eject
+\section{License}
+<<license>>=
+--Copyright The Numerical Algorithms Group Limited 1994.
+@
+<<*>>=
+<<license>>
+
+--Here is an input file which will plot a list of 2d data from a file.
+
+)clear all
+
+g := graphImage()$GRIMAGE
+p1 := point [0,0]$(Point DoubleFloat)
+p2 := point [.25,.25]$(Point DoubleFloat)
+p3 := point [.5,.5]$(Point DoubleFloat)
+p4 := point [.75,.75]$(Point DoubleFloat)
+p5 := point [1,1]$(Point DoubleFloat)
+component(g,p1)$GRIMAGE
+component(g,p2)$GRIMAGE
+appendPoint(g,p3)$GRIMAGE
+appendPoint(g,p4)$GRIMAGE
+appendPoint(g,p5)$GRIMAGE
+g1 := makeGraphImage(g)$GRIMAGE
+makeViewport2D(g1,[title("Graph Points")])$VIEW2D
+
+-- This line is equivalent to using component(g2,pi) for each point
+g2 := coerce([[p1],[p2],[p3],[p4],[p5]])$GRIMAGE
+v := viewport2D()$VIEW2D
+options(v,[title("Just Points")])
+putGraph(v,g2,1)
+makeViewport2D(v)$VIEW2D
+
+---------------------------------------------
+-- Create a 2d viewport of a list of points from a file
+---------------------------------------------
+
+drawList(lp:List Point DoubleFloat):VIEW2D ==
+ n := #lp
+ g := graphImage()$GRIMAGE
+ for p in lp repeat
+ point(g,p,pointColorDefault())$GRIMAGE
+-- component(g,p,pointColorDefault(),lineColorDefault(),pointSizeDefault())$GRIMAGE
+ gi := makeGraphImage(g)$GRIMAGE
+ makeViewport2D(gi,[title("Points")])$VIEW2D
+
+plotData2D(name, title) ==
+ f:File(DoubleFloat) := open(name,"input")
+ lp:LIST(Point DoubleFloat) := empty()
+ while ((x := readIfCan!(f)) case DoubleFloat) repeat
+ y : DoubleFloat := read!(f)
+ lp := cons(point [x,y]$(Point DoubleFloat), lp)
+ lp
+ close!(f)
+ drawList(lp)
+
+--plotData(``file.data'', ``2D Data Plot'')
+
+)clear all
+
+drawFun(f:DoubleFloat->DoubleFloat):VIEW2D ==
+ g := graphImage()$GRIMAGE
+ lp : LIST(Point DoubleFloat) := empty()
+ for i in 1..10 repeat
+ lp := cons(point [i, f(i)]$(Point DoubleFloat), lp)
+ component(g, lp, pointColorDefault(), lineColorDefault(), pointSizeDefault())
+ gi := makeGraphImage(g)$GRIMAGE
+ makeViewport2D(gi, [title("Points")])$VIEW2D
+@
+\eject
+\begin{thebibliography}{99}
+\bibitem{1} nothing
+\end{thebibliography}
+\end{document}