1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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}
|