plot tests adjusted and passed
svn: r9769
|
@ -61,12 +61,12 @@
|
||||||
1 0 32 #"(lib \"text-snipclass.ss\" \"xml\")\0"
|
1 0 32 #"(lib \"text-snipclass.ss\" \"xml\")\0"
|
||||||
1 0 15 #"test-case-box%\0"
|
1 0 15 #"test-case-box%\0"
|
||||||
2 0 1 6 #"wxloc\0"
|
2 0 1 6 #"wxloc\0"
|
||||||
00000000000 1 75 0 1 #"\0"
|
00000000000 1 77 0 1 #"\0"
|
||||||
0 75 1 #"\0"
|
0 75 1 #"\0"
|
||||||
0 11 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 9
|
0 11 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 9
|
||||||
#"Standard\0"
|
#"Standard\0"
|
||||||
0 75 11 #" Monospace\0"
|
0 75 11 #" Monospace\0"
|
||||||
0 11 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 2 1
|
0 14 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 2 1
|
||||||
#"\0"
|
#"\0"
|
||||||
0 -1 1 #"\0"
|
0 -1 1 #"\0"
|
||||||
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 -1 -1 2 24
|
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 -1 -1 2 24
|
||||||
|
@ -198,7 +198,22 @@
|
||||||
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 8 24
|
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 8 24
|
||||||
#"drscheme:text:ports err\0"
|
#"drscheme:text:ports err\0"
|
||||||
0 -1 1 #"\0"
|
0 -1 1 #"\0"
|
||||||
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 0 1
|
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 4 1
|
||||||
|
#"\0"
|
||||||
|
0 71 1 #"\0"
|
||||||
|
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 -1 -1 4 1
|
||||||
|
#"\0"
|
||||||
|
0 -1 1 #"\0"
|
||||||
|
1 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 255 0 0 0 -1 -1 4 1
|
||||||
|
#"\0"
|
||||||
|
0 71 1 #"\0"
|
||||||
|
1 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 255 0 0 0 -1 -1 4 1
|
||||||
|
#"\0"
|
||||||
|
0 71 1 #"\0"
|
||||||
|
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 100 0 0 0 0 -1 -1 0 1
|
||||||
|
#"\0"
|
||||||
|
0 75 11 #" Monospace\0"
|
||||||
|
0 11 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 1
|
||||||
#"\0"
|
#"\0"
|
||||||
0 75 1 #"\0"
|
0 75 1 #"\0"
|
||||||
0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 1
|
0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 1
|
||||||
|
@ -270,34 +285,16 @@
|
||||||
1 0 -1 -1 94 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 1
|
1 0 -1 -1 94 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 1
|
||||||
#"\0"
|
#"\0"
|
||||||
0 -1 1 #"\0"
|
0 -1 1 #"\0"
|
||||||
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 200 0 0 0 0 0 -1 -1 4 1
|
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 200 0 0 0 0 0 -1 -1 0 1
|
||||||
#"\0"
|
|
||||||
0 71 1 #"\0"
|
|
||||||
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 -1 -1 4 1
|
|
||||||
#"\0"
|
#"\0"
|
||||||
0 -1 1 #"\0"
|
0 -1 1 #"\0"
|
||||||
1 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 255 0 0 0 -1 -1 4 1
|
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 200 0 0 0 0 0 -1 -1
|
||||||
#"\0"
|
00000000002 0 00000000000 3 00000000000 125 0 26 3 12 #"#lang scheme"
|
||||||
0 71 1 #"\0"
|
|
||||||
1 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 255 0 0 0 -1 -1 4 1
|
|
||||||
#"\0"
|
|
||||||
0 71 1 #"\0"
|
|
||||||
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 100 0 0 0 0 -1 -1
|
|
||||||
00000000002 0 00000000000 3 00000000000 159 0 22 3 1 #"("
|
|
||||||
0 0 14 3 7 #"require"
|
|
||||||
0 0 4 3 1 #" "
|
|
||||||
0 0 22 3 1 #"("
|
|
||||||
0 0 14 3 3 #"lib"
|
|
||||||
0 0 4 3 1 #" "
|
|
||||||
0 0 19 3 9 #"\"plot.ss\""
|
|
||||||
0 0 4 3 1 #" "
|
|
||||||
0 0 19 3 6 #"\"plot\""
|
|
||||||
0 0 22 3 2 #"))"
|
|
||||||
0 0 4 29 1 #"\n"
|
0 0 4 29 1 #"\n"
|
||||||
0 0 22 3 1 #"("
|
0 0 22 3 1 #"("
|
||||||
0 0 14 3 7 #"require"
|
0 0 14 3 7 #"require"
|
||||||
0 0 4 3 1 #" "
|
0 0 4 3 1 #" "
|
||||||
0 0 14 3 9 #"mzlib/etc"
|
0 0 14 3 4 #"plot"
|
||||||
0 0 22 3 1 #")"
|
0 0 22 3 1 #")"
|
||||||
0 0 4 29 1 #"\n"
|
0 0 4 29 1 #"\n"
|
||||||
0 0 4 29 1 #"\n"
|
0 0 4 29 1 #"\n"
|
||||||
|
@ -332,6 +329,9 @@
|
||||||
0 0 14 3 1 #"x"
|
0 0 14 3 1 #"x"
|
||||||
0 0 22 3 3 #")))"
|
0 0 22 3 3 #")))"
|
||||||
0 0 4 3 1 #" "
|
0 0 4 3 1 #" "
|
||||||
|
0 0 17 3 25 #"; a random list of points"
|
||||||
|
0 0 4 29 1 #"\n"
|
||||||
|
0 0 4 3 7 #" "
|
||||||
0 0 22 3 1 #"("
|
0 0 22 3 1 #"("
|
||||||
0 0 14 3 10 #"build-list"
|
0 0 14 3 10 #"build-list"
|
||||||
0 0 4 3 1 #" "
|
0 0 4 3 1 #" "
|
||||||
|
@ -349,43 +349,18 @@
|
||||||
0 0 4 3 1 #" "
|
0 0 4 3 1 #" "
|
||||||
0 0 14 3 1 #"x"
|
0 0 14 3 1 #"x"
|
||||||
0 0 22 3 5 #")))))"
|
0 0 22 3 5 #")))))"
|
||||||
0 0 4 3 1 #" "
|
|
||||||
0 0 17 3 1 #";"
|
|
||||||
0 0 17 3 1 #" "
|
|
||||||
0 0 17 3 1 #"a"
|
|
||||||
0 0 17 3 1 #" "
|
|
||||||
0 0 17 3 1 #"r"
|
|
||||||
0 0 17 3 1 #"a"
|
|
||||||
0 0 17 3 1 #"n"
|
|
||||||
0 0 17 3 1 #"d"
|
|
||||||
0 0 17 3 1 #"o"
|
|
||||||
0 0 17 3 1 #"m"
|
|
||||||
0 0 17 3 1 #" "
|
|
||||||
0 0 17 3 1 #"l"
|
|
||||||
0 0 17 3 1 #"i"
|
|
||||||
0 0 17 3 1 #"s"
|
|
||||||
0 0 17 3 1 #"t"
|
|
||||||
0 0 17 3 1 #" "
|
|
||||||
0 0 17 3 1 #"o"
|
|
||||||
0 0 17 3 1 #"f"
|
|
||||||
0 0 17 3 1 #" "
|
|
||||||
0 0 17 3 1 #"p"
|
|
||||||
0 0 17 3 1 #"o"
|
|
||||||
0 0 17 3 1 #"i"
|
|
||||||
0 0 17 3 3 #"nts"
|
|
||||||
0 0 4 29 1 #"\n"
|
0 0 4 29 1 #"\n"
|
||||||
0 0 4 3 1 #" "
|
0 0 4 3 1 #" "
|
||||||
0 0 22 3 1 #"("
|
0 0 22 3 1 #"#"
|
||||||
0 0 14 3 5 #"x-max"
|
0 0 22 3 6 #":x-max"
|
||||||
|
0 0 4 3 1 #" "
|
||||||
|
0 0 20 3 2 #"30"
|
||||||
|
0 0 4 3 1 #" "
|
||||||
|
0 0 22 3 1 #"#"
|
||||||
|
0 0 22 3 6 #":y-max"
|
||||||
0 0 4 3 1 #" "
|
0 0 4 3 1 #" "
|
||||||
0 0 20 3 2 #"30"
|
0 0 20 3 2 #"30"
|
||||||
0 0 22 3 1 #")"
|
0 0 22 3 1 #")"
|
||||||
0 0 4 3 1 #" "
|
|
||||||
0 0 22 3 1 #"("
|
|
||||||
0 0 14 3 5 #"y-max"
|
|
||||||
0 0 4 3 1 #" "
|
|
||||||
0 0 20 3 2 #"30"
|
|
||||||
0 0 22 3 2 #"))"
|
|
||||||
0 0 4 29 1 #"\n"
|
0 0 4 29 1 #"\n"
|
||||||
0 0 4 29 1 #"\n"
|
0 0 4 29 1 #"\n"
|
||||||
0 0 17 3 1 #";"
|
0 0 17 3 1 #";"
|
||||||
|
@ -409,8 +384,7 @@
|
||||||
0 0 17 3 1 #"n"
|
0 0 17 3 1 #"n"
|
||||||
0 0 17 3 1 #"g"
|
0 0 17 3 1 #"g"
|
||||||
0 0 17 3 1 #" "
|
0 0 17 3 1 #" "
|
||||||
0 0 17 3 1 #"l"
|
0 0 17 3 2 #"li"
|
||||||
0 0 17 3 1 #"i"
|
|
||||||
0 0 17 3 1 #"k"
|
0 0 17 3 1 #"k"
|
||||||
0 0 17 3 1 #"e"
|
0 0 17 3 1 #"e"
|
||||||
0 0 17 3 1 #" "
|
0 0 17 3 1 #" "
|
||||||
|
@ -436,11 +410,9 @@
|
||||||
0 0 17 3 1 #"r"
|
0 0 17 3 1 #"r"
|
||||||
0 0 17 3 1 #"e"
|
0 0 17 3 1 #"e"
|
||||||
0 0 17 3 1 #" "
|
0 0 17 3 1 #" "
|
||||||
0 0 17 3 1 #"r"
|
0 0 17 3 6 #"random"
|
||||||
0 0 17 3 1 #"a"
|
|
||||||
0 0 17 3 4 #"ndom"
|
|
||||||
0 0 4 29 1 #"\n"
|
|
||||||
0 0 4 29 1 #"\n"
|
0 0 4 29 1 #"\n"
|
||||||
|
0 0 17 3 1 #";"
|
||||||
0 3 00000000037 4 1 #"\0"
|
0 3 00000000037 4 1 #"\0"
|
||||||
2 -1 -1 0 0 0 00000000013 500
|
2 -1 -1 0 0 0 00000000013 500
|
||||||
(
|
(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#lang scheme
|
||||||
(require plot)
|
(require plot)
|
||||||
|
|
||||||
(require mzlib/class plot/plot-extend)
|
(require mzlib/class plot/plot-extend)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
#lang scheme
|
||||||
(require plot)
|
(require plot)
|
||||||
(require mzlib/etc)
|
|
||||||
|
|
||||||
(plot (line identity (color 'red)))
|
(plot (line (lambda (x) x) #:color 'red))
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#lang scheme
|
||||||
(require plot)
|
(require plot)
|
||||||
|
|
||||||
(plot (line (lambda (x) (sin x)) (color 'red)))
|
(plot (line sin #:color 'red))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
#lang scheme
|
||||||
(require plot)
|
(require plot)
|
||||||
|
|
||||||
(plot
|
(plot (vector-field (gradient (lambda (x y) (* (sin x) (cos y)))) #:samples 25)
|
||||||
(vector-field (gradient (lambda (x y) (* (sin x) (cos y)))) (samples 25))
|
#:title "gradient field of F(x,y) = sin(x) * sin(y)")
|
||||||
(title "gradient field of F(x,y) = sin(x) * sin(y)"))
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
#lang scheme
|
||||||
(require plot)
|
(require plot)
|
||||||
|
|
||||||
|
|
||||||
(define (trig x y) (* (sin x) (sin y)))
|
(define (trig x y) (* (sin x) (sin y)))
|
||||||
(plot (shade trig)
|
(plot (shade trig)
|
||||||
(x-min -1.5) (x-max 1.5) (y-min -1.5) (y-max 1.5)
|
#:x-min -1.5 #:x-max 1.5 #:y-min -1.5 #:y-max 1.5
|
||||||
(title "shdade of F(x,y) = sin(x) * sin(y)"))
|
#:title "shdade of F(x,y) = sin(x) * sin(y)")
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
#lang scheme
|
||||||
(require plot)
|
(require plot)
|
||||||
|
|
||||||
(define (trig x y) (* (sin x) (sin y)))
|
(define (trig x y) (* (sin x) (sin y)))
|
||||||
|
|
||||||
(plot (contour trig)
|
(plot (contour trig)
|
||||||
(x-min -1.5) (x-max 1.5) (y-min -1.5) (y-max 1.5)
|
#:x-min -1.5 #:x-max 1.5 #:y-min -1.5 #:y-max 1.5
|
||||||
(title "contours of F(x,y) = sin(x) * sin(y)"))
|
#:title "contours of F(x,y) = sin(x) * sin(y)")
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
#lang scheme
|
||||||
(require plot)
|
(require plot)
|
||||||
|
|
||||||
(define (trig x y) (* (sin x) (sin y)))
|
(define (trig x y) (* (sin x) (sin y)))
|
||||||
|
|
||||||
(plot (vector-field (gradient trig) '((samples 25)))
|
(plot (vector-field (gradient trig) #:samples 25)
|
||||||
(x-min -1.5) (x-max 1.5) (y-min -1.5) (y-max 1.5)
|
#:x-min -1.5 #:x-max 1.5 #:y-min -1.5 #:y-max 1.5
|
||||||
(title "gradient field of F(x,y) = sin(x) * sin(y)"))
|
#:title "gradient field of F(x,y) = sin(x) * sin(y)")
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
#lang scheme
|
||||||
(require plot)
|
(require plot)
|
||||||
|
|
||||||
(define (trig x y) (* (sin x) (sin y)))
|
(define (trig x y) (* (sin x) (sin y)))
|
||||||
|
|
||||||
|
(plot (mix (shade trig)
|
||||||
(plot (mix
|
|
||||||
(shade trig)
|
|
||||||
(contour trig)
|
(contour trig)
|
||||||
(vector-field (gradient trig ) (samples 25)))
|
(vector-field (gradient trig) #:samples 25))
|
||||||
(x-min -1.5) (x-max 1.5) (y-min -1.5) (y-max 1.5)
|
#:x-min -1.5 #:x-max 1.5 #:y-min -1.5 #:y-max 1.5
|
||||||
(title "gradient field +shdade + contours of F(x,y) = sin(x) * sin(y)"))
|
#:title "gradient field +shdade + contours of F(x,y) = sin(x) * sin(y)")
|
||||||
|
|
||||||
(plot3d (mesh3d trig)
|
(plot3d (mesh3d trig)
|
||||||
(x-min -3.5) (x-max 3.5) (y-min -3.5) (y-max 3.5) (z-min -1.0) (z-max 1.5) (bgcolor '(0 0 0)) (fgcolor '(255 0 0)))
|
#:x-min -3.5 #:x-max 3.5 #:y-min -3.5 #:y-max 3.5 #:z-min -1.0 #:z-max 1.5
|
||||||
|
#:bgcolor '(0 0 0) #:fgcolor '(255 0 0))
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#lang scheme
|
||||||
(require plot)
|
(require plot)
|
||||||
|
|
||||||
(define x-vals (build-list 15 (lambda (x) x) ))
|
(define x-vals (build-list 15 (lambda (x) x) ))
|
||||||
|
@ -12,12 +13,12 @@
|
||||||
|
|
||||||
(define params
|
(define params
|
||||||
(fit gues-fun
|
(fit gues-fun
|
||||||
((a 1) (b 1))
|
'((a 1) (b 1))
|
||||||
(map vector x-vals z-vals errors)))
|
(map vector x-vals z-vals errors)))
|
||||||
|
|
||||||
(plot (mix
|
(plot (mix
|
||||||
(points (map vector x-vals z-vals))
|
(points (map vector x-vals z-vals))
|
||||||
(line (lambda (x)
|
(line (lambda (x)
|
||||||
(apply gues-fun x (fit-result-final-params params)))))
|
(apply gues-fun x (fit-result-final-params params)))))
|
||||||
(x-min -1) (x-max 20)
|
#:x-min -1 #:x-max 20
|
||||||
(y-min -1) (y-max 10))
|
#:y-min -1 #:y-max 10)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
;; This is data from the Cavendish experiment
|
#lang scheme
|
||||||
|
|
||||||
|
;; This is data from the Cavendish experiment
|
||||||
(define raw-data
|
(define raw-data
|
||||||
'((0.0 -14.7 3.6)
|
'((0.0 -14.7 3.6)
|
||||||
(1.0 8.6 3.6)
|
(1.0 8.6 3.6)
|
||||||
|
@ -55,33 +56,24 @@
|
||||||
|
|
||||||
(require plot)
|
(require plot)
|
||||||
|
|
||||||
(plot (mix (points experemental-data (symbol 'circle))
|
(plot (mix (points experemental-data #:sym 'circle)
|
||||||
(error-bars experemental-data))
|
(error-bars experemental-data))
|
||||||
(x-min 0) (x-max 40)
|
#:x-min 0 #:x-max 40
|
||||||
(y-min -40) (y-max 50)
|
#:y-min -40 #:y-max 50
|
||||||
(width 400) (height 300))
|
#:width 400 #:height 300)
|
||||||
|
|
||||||
(define
|
(define (theta x a tau phi T theta0)
|
||||||
(theta x a tau phi T theta0)
|
(+ theta0
|
||||||
(+
|
(* a (exp (/ x tau -1)) (sin (+ phi (/ (* 2 pi x) T))))))
|
||||||
theta0
|
|
||||||
(* a
|
|
||||||
(exp (/ x tau -1))
|
|
||||||
(sin (+ phi (/ (* 2 pi x) T))))))
|
|
||||||
|
|
||||||
(define result
|
(define result
|
||||||
(fit
|
(fit theta '((a 40) (tau 15) (phi -0.5) (T 15) (theta0 10)) experemental-data))
|
||||||
theta
|
|
||||||
((a 40) (tau 15) (phi -0.5) (T 15) (theta0 10))
|
|
||||||
experemental-data))
|
|
||||||
|
|
||||||
|
(plot (mix (points (map vector times vals) #:sym 'square #:color 'black)
|
||||||
(plot (mix
|
|
||||||
(points (map vector times vals) (symobol 'square) (color 'black))
|
|
||||||
(error-bars experemental-data)
|
(error-bars experemental-data)
|
||||||
(line (fit-result-function result) (color 'green)))
|
(line (fit-result-function result) #:color 'green))
|
||||||
(x-min -5) (x-max 40)
|
#:x-min -5 #:x-max 40
|
||||||
(y-min -40) (y-max 50))
|
#:y-min -40 #:y-max 50)
|
||||||
|
|
||||||
(fit-result-final-params result)
|
(fit-result-final-params result)
|
||||||
;(pretty-print result)
|
;(pretty-print result)
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
shade surface))
|
shade surface))
|
||||||
(only-in "plot.ss"
|
(only-in "plot.ss"
|
||||||
mix
|
mix
|
||||||
derivative gradient make-vec)
|
derivative gradient make-vec
|
||||||
|
mesh3d)
|
||||||
(only-in "fit.ss" fit-int))
|
(only-in "fit.ss" fit-int))
|
||||||
|
|
||||||
(provide plot
|
(provide plot
|
||||||
|
@ -25,7 +26,8 @@
|
||||||
mix
|
mix
|
||||||
derivative
|
derivative
|
||||||
gradient
|
gradient
|
||||||
make-vec)
|
make-vec
|
||||||
|
mesh3d)
|
||||||
|
|
||||||
(define-syntax-rule (out-fit-struct)
|
(define-syntax-rule (out-fit-struct)
|
||||||
(begin
|
(begin
|
||||||
|
@ -50,6 +52,7 @@
|
||||||
#:fgcolor [fgcolor '(0 0 0)]
|
#:fgcolor [fgcolor '(0 0 0)]
|
||||||
#:bgcolor [bgcolor '(255 255 255)]
|
#:bgcolor [bgcolor '(255 255 255)]
|
||||||
#:lncolor [lncolor '(255 0 0)]
|
#:lncolor [lncolor '(255 0 0)]
|
||||||
|
#:out-file [out-file #f]
|
||||||
arg-extra ...)
|
arg-extra ...)
|
||||||
(orig:plot data
|
(orig:plot data
|
||||||
[width width]
|
[width width]
|
||||||
|
@ -64,6 +67,7 @@
|
||||||
[fgcolor fgcolor]
|
[fgcolor fgcolor]
|
||||||
[bgcolor bgcolor]
|
[bgcolor bgcolor]
|
||||||
[lncolor lncolor]
|
[lncolor lncolor]
|
||||||
|
[out-file out-file]
|
||||||
init-extra ...)))
|
init-extra ...)))
|
||||||
|
|
||||||
(define-plot plot orig:plot [] [])
|
(define-plot plot orig:plot [] [])
|
||||||
|
@ -114,11 +118,13 @@
|
||||||
(define (vector-field f
|
(define (vector-field f
|
||||||
#:width [width 1]
|
#:width [width 1]
|
||||||
#:color [color 'red]
|
#:color [color 'red]
|
||||||
#:style [style 'scaled])
|
#:style [style 'scaled]
|
||||||
|
#:samples [samples 20])
|
||||||
(orig:vector-field f
|
(orig:vector-field f
|
||||||
[width width]
|
[width width]
|
||||||
[color color]
|
[color color]
|
||||||
[style style]))
|
[style style]
|
||||||
|
[samples samples]))
|
||||||
|
|
||||||
(define (contour f
|
(define (contour f
|
||||||
#:samples [samples 50]
|
#:samples [samples 50]
|
||||||
|
|
|
@ -171,8 +171,7 @@
|
||||||
plot-line
|
plot-line
|
||||||
plot-contours
|
plot-contours
|
||||||
plot-shades
|
plot-shades
|
||||||
fill
|
fill)
|
||||||
)
|
|
||||||
|
|
||||||
; set-labels : string string string -> nothing
|
; set-labels : string string string -> nothing
|
||||||
; sets the x, y and title lables
|
; sets the x, y and title lables
|
||||||
|
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.9 KiB |
|
@ -1,24 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#|
|
#| -*- scheme -*-
|
||||||
exec mred -u "$0" "$@"
|
exec mred "$0" "$@"
|
||||||
|#
|
|#
|
||||||
(module run-tests mzscheme
|
#lang scheme
|
||||||
|
(require plot mzlib/md5)
|
||||||
|
|
||||||
(require plot
|
|
||||||
mzlib/md5
|
|
||||||
mzlib/pretty)
|
|
||||||
|
|
||||||
|
|
||||||
;; thisi should be big enough to read thse files
|
|
||||||
(define (read-file file)
|
(define (read-file file)
|
||||||
(with-input-from-file file (lambda () (read-bytes 100000))))
|
(with-input-from-file file (lambda () (read-bytes (file-size file)))))
|
||||||
|
|
||||||
(define-syntax run-test
|
(define-syntax run-test
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
[(_ description (plot args ...) file-name)
|
[(_ description (plot args ...) file-name)
|
||||||
(let* ([result-file-name (string-append file-name "-out.png")]
|
(let* ([result-file-name (string-append file-name "-out.png")]
|
||||||
[expected-file-name (string-append file-name ".png")])
|
[expected-file-name (string-append file-name ".png")])
|
||||||
(plot args ... (out-file result-file-name))
|
(plot args ... #:out-file result-file-name)
|
||||||
;; WILL COMPARE by MD5 hash.
|
;; WILL COMPARE by MD5 hash.
|
||||||
(printf "testing \"~a\" ... " description)
|
(printf "testing \"~a\" ... " description)
|
||||||
(if (equal? (md5 (read-file result-file-name))
|
(if (equal? (md5 (read-file result-file-name))
|
||||||
|
@ -28,60 +23,47 @@ exec mred -u "$0" "$@"
|
||||||
expected-file-name
|
expected-file-name
|
||||||
result-file-name)))]))
|
result-file-name)))]))
|
||||||
|
|
||||||
|
|
||||||
(run-test "Line"
|
(run-test "Line"
|
||||||
(plot
|
(plot (line (lambda (x) x) #:color 'red))
|
||||||
(line (lambda (x) x) (color 'red)))
|
|
||||||
"red-identity")
|
"red-identity")
|
||||||
|
|
||||||
|
(run-test "Vector Field"
|
||||||
|
(plot (vector-field (gradient (lambda (x y) (* (sin x) (cos y))))
|
||||||
(run-test
|
#:samples 25)
|
||||||
"Vector Field"
|
#:title "gradient field of F(x,y) = sin(x) * sin(y)")
|
||||||
(plot
|
|
||||||
(vector-field
|
|
||||||
(gradient (lambda (x y) (* (sin x) (cos y))))
|
|
||||||
(samples 25))
|
|
||||||
(title "gradient field of F(x,y) = sin(x) * sin(y)"))
|
|
||||||
"vector-field")
|
"vector-field")
|
||||||
|
|
||||||
(define (trig x y) (* (sin x) (sin y)))
|
(define (trig x y) (* (sin x) (sin y)))
|
||||||
|
|
||||||
(run-test
|
(run-test "Shading"
|
||||||
"Shading"
|
|
||||||
(plot (shade trig)
|
(plot (shade trig)
|
||||||
(x-min -1.5) (x-max 1.5) (y-min -1.5) (y-max 1.5)
|
#:x-min -1.5 #:x-max 1.5 #:y-min -1.5 #:y-max 1.5
|
||||||
(title "shdade of F(x,y) = sin(x) * sin(y)"))
|
#:title "shdade of F(x,y) = sin(x) * sin(y)")
|
||||||
"shade")
|
"shade")
|
||||||
|
|
||||||
(run-test
|
(run-test "Contours"
|
||||||
"Contours"
|
|
||||||
(plot (contour trig)
|
(plot (contour trig)
|
||||||
(x-min -1.5) (x-max 1.5) (y-min -1.5) (y-max 1.5)
|
#:x-min -1.5 #:x-max 1.5 #:y-min -1.5 #:y-max 1.5
|
||||||
(title "contours of F(x,y) = sin(x) * sin(y)"))
|
#:title "contours of F(x,y) = sin(x) * sin(y)")
|
||||||
"contours")
|
"contours")
|
||||||
|
|
||||||
(run-test
|
(run-test "Mix of all three"
|
||||||
"Mix of all three"
|
(plot (mix (shade trig)
|
||||||
(plot (mix
|
|
||||||
(shade trig)
|
|
||||||
(contour trig)
|
(contour trig)
|
||||||
(vector-field (gradient trig ) (samples 25)))
|
(vector-field (gradient trig) #:samples 25))
|
||||||
(x-min -1.5) (x-max 1.5) (y-min -1.5) (y-max 1.5)
|
#:x-min -1.5 #:x-max 1.5 #:y-min -1.5 #:y-max 1.5
|
||||||
(title
|
#:title "gradient field & shade & contours")
|
||||||
"gradient field +shdade + contours of F(x,y) = sin(x) * sin(y)"))
|
|
||||||
"mix")
|
"mix")
|
||||||
|
|
||||||
(run-test
|
(run-test "3d mesg"
|
||||||
"3d mesg"
|
|
||||||
(plot3d (mesh3d trig)
|
(plot3d (mesh3d trig)
|
||||||
(x-min -3.5) (x-max 3.5) (y-min -3.5) (y-max 3.5) (z-min -1.0) (z-max 1.5) (bgcolor '(0 0 0)) (fgcolor '(255 0 0)))
|
#:x-min -3.5 #:x-max 3.5
|
||||||
|
#:y-min -3.5 #:y-max 3.5
|
||||||
|
#:z-min -1.0 #:z-max 1.5
|
||||||
|
#:bgcolor '(0 0 0) #:fgcolor '(255 0 0))
|
||||||
"3d-mesh")
|
"3d-mesh")
|
||||||
|
|
||||||
(require mzlib/class
|
(require plot/plot-extend)
|
||||||
(lib "plot-extend.ss" "plot")
|
|
||||||
mzlib/etc)
|
|
||||||
|
|
||||||
|
|
||||||
; (number -> number) mumbo-jumbo -> 2d-renderer
|
; (number -> number) mumbo-jumbo -> 2d-renderer
|
||||||
(define-plot-type dashed-line
|
(define-plot-type dashed-line
|
||||||
|
@ -101,14 +83,10 @@ exec mred -u "$0" "$@"
|
||||||
(map (lambda (x) (vector x (fun x))) dash)))
|
(map (lambda (x) (vector x (fun x))) dash)))
|
||||||
x-lists)))
|
x-lists)))
|
||||||
|
|
||||||
(run-test
|
(run-test "Simple plot-extend"
|
||||||
"Simple plot-extend"
|
(plot (dashed-line (lambda (x) x) [color 'red]))
|
||||||
(plot (dashed-line (lambda (x) x) (color 'red)))
|
|
||||||
"dashed-line")
|
"dashed-line")
|
||||||
|
|
||||||
(run-test
|
(run-test "canvas sizing"
|
||||||
"canvas sizing"
|
(plot (line sin) #:height 100 #:width 100)
|
||||||
(plot (line sin) (height 100) (width 100))
|
|
||||||
"size")
|
"size")
|
||||||
|
|
||||||
)
|
|
||||||
|
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 7.1 KiB |