plot tests adjusted and passed
svn: r9769
|
@ -61,12 +61,12 @@
|
|||
1 0 32 #"(lib \"text-snipclass.ss\" \"xml\")\0"
|
||||
1 0 15 #"test-case-box%\0"
|
||||
2 0 1 6 #"wxloc\0"
|
||||
00000000000 1 75 0 1 #"\0"
|
||||
00000000000 1 77 0 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
|
||||
#"Standard\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 -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
|
||||
|
@ -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
|
||||
#"drscheme:text:ports err\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 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
|
||||
|
@ -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
|
||||
#"\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
|
||||
#"\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
|
||||
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 -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
|
||||
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 #"))"
|
||||
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
|
||||
00000000002 0 00000000000 3 00000000000 125 0 26 3 12 #"#lang scheme"
|
||||
0 0 4 29 1 #"\n"
|
||||
0 0 22 3 1 #"("
|
||||
0 0 14 3 7 #"require"
|
||||
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 4 29 1 #"\n"
|
||||
0 0 4 29 1 #"\n"
|
||||
|
@ -332,6 +329,9 @@
|
|||
0 0 14 3 1 #"x"
|
||||
0 0 22 3 3 #")))"
|
||||
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 14 3 10 #"build-list"
|
||||
0 0 4 3 1 #" "
|
||||
|
@ -349,43 +349,18 @@
|
|||
0 0 4 3 1 #" "
|
||||
0 0 14 3 1 #"x"
|
||||
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 3 1 #" "
|
||||
0 0 22 3 1 #"("
|
||||
0 0 14 3 5 #"x-max"
|
||||
0 0 22 3 1 #"#"
|
||||
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 20 3 2 #"30"
|
||||
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 17 3 1 #";"
|
||||
|
@ -409,8 +384,7 @@
|
|||
0 0 17 3 1 #"n"
|
||||
0 0 17 3 1 #"g"
|
||||
0 0 17 3 1 #" "
|
||||
0 0 17 3 1 #"l"
|
||||
0 0 17 3 1 #"i"
|
||||
0 0 17 3 2 #"li"
|
||||
0 0 17 3 1 #"k"
|
||||
0 0 17 3 1 #"e"
|
||||
0 0 17 3 1 #" "
|
||||
|
@ -436,11 +410,9 @@
|
|||
0 0 17 3 1 #"r"
|
||||
0 0 17 3 1 #"e"
|
||||
0 0 17 3 1 #" "
|
||||
0 0 17 3 1 #"r"
|
||||
0 0 17 3 1 #"a"
|
||||
0 0 17 3 4 #"ndom"
|
||||
0 0 4 29 1 #"\n"
|
||||
0 0 17 3 6 #"random"
|
||||
0 0 4 29 1 #"\n"
|
||||
0 0 17 3 1 #";"
|
||||
0 3 00000000037 4 1 #"\0"
|
||||
2 -1 -1 0 0 0 00000000013 500
|
||||
(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#lang scheme
|
||||
(require plot)
|
||||
|
||||
(require mzlib/class plot/plot-extend)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#lang scheme
|
||||
(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)
|
||||
|
||||
(plot (line (lambda (x) (sin x)) (color 'red)))
|
||||
(plot (line sin #:color 'red))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#lang scheme
|
||||
(require plot)
|
||||
|
||||
(plot
|
||||
(vector-field (gradient (lambda (x y) (* (sin x) (cos y)))) (samples 25))
|
||||
(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)")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#lang scheme
|
||||
(require plot)
|
||||
|
||||
|
||||
(define (trig x y) (* (sin x) (sin y)))
|
||||
(plot (shade trig)
|
||||
(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)"))
|
||||
#: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)")
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#lang scheme
|
||||
(require plot)
|
||||
|
||||
(define (trig x y) (* (sin x) (sin y)))
|
||||
|
||||
(plot (contour trig)
|
||||
(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)"))
|
||||
#: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)")
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#lang scheme
|
||||
(require plot)
|
||||
|
||||
(define (trig x y) (* (sin x) (sin y)))
|
||||
|
||||
(plot (vector-field (gradient trig) '((samples 25)))
|
||||
(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)"))
|
||||
(plot (vector-field (gradient trig) #:samples 25)
|
||||
#: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)")
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#lang scheme
|
||||
(require plot)
|
||||
|
||||
(define (trig x y) (* (sin x) (sin y)))
|
||||
|
||||
|
||||
(plot (mix
|
||||
(shade trig)
|
||||
(contour trig)
|
||||
(vector-field (gradient trig ) (samples 25)))
|
||||
(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)"))
|
||||
(plot (mix (shade trig)
|
||||
(contour trig)
|
||||
(vector-field (gradient trig) #:samples 25))
|
||||
#: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)")
|
||||
|
||||
(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)
|
||||
|
||||
(define x-vals (build-list 15 (lambda (x) x) ))
|
||||
|
@ -12,12 +13,12 @@
|
|||
|
||||
(define params
|
||||
(fit gues-fun
|
||||
((a 1) (b 1))
|
||||
'((a 1) (b 1))
|
||||
(map vector x-vals z-vals errors)))
|
||||
|
||||
(plot (mix
|
||||
(points (map vector x-vals z-vals))
|
||||
(line (lambda (x)
|
||||
(apply gues-fun x (fit-result-final-params params)))))
|
||||
(x-min -1) (x-max 20)
|
||||
(y-min -1) (y-max 10))
|
||||
#:x-min -1 #:x-max 20
|
||||
#: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
|
||||
'((0.0 -14.7 3.6)
|
||||
(1.0 8.6 3.6)
|
||||
|
@ -7,39 +8,39 @@
|
|||
(3.1 46.7 3.4)
|
||||
(4.2 47.4 3.5)
|
||||
(5.2 36.5 3.4)
|
||||
(6.2 37.0 10.3)
|
||||
(7.2 5.1 3.4)
|
||||
(8.2 -11.2 3.4)
|
||||
(9.1 -22.4 3.5)
|
||||
(10.0 -35.5 3.6)
|
||||
(11.0 -33.6 3.9)
|
||||
(12.0 -21.1 3.9)
|
||||
(12.9 -15.0 4.2)
|
||||
(13.8 -1.6 2.7)
|
||||
(14.9 19.5 3.2)
|
||||
(15.9 27.5 2.8)
|
||||
(17.0 32.6 3.5)
|
||||
(17.9 27.5 2.7)
|
||||
(18.9 20.2 3.3)
|
||||
(20.0 13.8 3.4)
|
||||
(21.0 -1.3 4.2)
|
||||
(22.0 -24.5 6.7)
|
||||
(23.0 -25.0 3.3)
|
||||
(24.0 -25.0 3.1)
|
||||
(25.0 -20.2 3.6)
|
||||
(26.0 -9.9 3.2)
|
||||
(27.0 5.8 3.2)
|
||||
(28.0 14.7 3.0)
|
||||
(29.0 21.8 3.5)
|
||||
(30.0 29.8 2.7)
|
||||
(31.0 21.4 4.1)
|
||||
(32.0 24.6 2.7)
|
||||
(32.9 25.8 12.0)
|
||||
(33.8 0.6 2.9)
|
||||
(34.7 -16.6 3.2)
|
||||
(35.7 -24.0 3.7)
|
||||
(36.6 -24.6 3.8)
|
||||
(37.7 -19.8 3.5)))
|
||||
(6.2 37.0 10.3)
|
||||
(7.2 5.1 3.4)
|
||||
(8.2 -11.2 3.4)
|
||||
(9.1 -22.4 3.5)
|
||||
(10.0 -35.5 3.6)
|
||||
(11.0 -33.6 3.9)
|
||||
(12.0 -21.1 3.9)
|
||||
(12.9 -15.0 4.2)
|
||||
(13.8 -1.6 2.7)
|
||||
(14.9 19.5 3.2)
|
||||
(15.9 27.5 2.8)
|
||||
(17.0 32.6 3.5)
|
||||
(17.9 27.5 2.7)
|
||||
(18.9 20.2 3.3)
|
||||
(20.0 13.8 3.4)
|
||||
(21.0 -1.3 4.2)
|
||||
(22.0 -24.5 6.7)
|
||||
(23.0 -25.0 3.3)
|
||||
(24.0 -25.0 3.1)
|
||||
(25.0 -20.2 3.6)
|
||||
(26.0 -9.9 3.2)
|
||||
(27.0 5.8 3.2)
|
||||
(28.0 14.7 3.0)
|
||||
(29.0 21.8 3.5)
|
||||
(30.0 29.8 2.7)
|
||||
(31.0 21.4 4.1)
|
||||
(32.0 24.6 2.7)
|
||||
(32.9 25.8 12.0)
|
||||
(33.8 0.6 2.9)
|
||||
(34.7 -16.6 3.2)
|
||||
(35.7 -24.0 3.7)
|
||||
(36.6 -24.6 3.8)
|
||||
(37.7 -19.8 3.5)))
|
||||
|
||||
; first column is time data, second is result, third is error. to parse them out...
|
||||
(require mzlib/math)
|
||||
|
@ -55,33 +56,24 @@
|
|||
|
||||
(require plot)
|
||||
|
||||
(plot (mix (points experemental-data (symbol 'circle))
|
||||
(plot (mix (points experemental-data #:sym 'circle)
|
||||
(error-bars experemental-data))
|
||||
(x-min 0) (x-max 40)
|
||||
(y-min -40) (y-max 50)
|
||||
(width 400) (height 300))
|
||||
#:x-min 0 #:x-max 40
|
||||
#:y-min -40 #:y-max 50
|
||||
#:width 400 #:height 300)
|
||||
|
||||
(define
|
||||
(theta x a tau phi T theta0)
|
||||
(+
|
||||
theta0
|
||||
(* a
|
||||
(exp (/ x tau -1))
|
||||
(sin (+ phi (/ (* 2 pi x) T))))))
|
||||
(define (theta x a tau phi T theta0)
|
||||
(+ theta0
|
||||
(* a (exp (/ x tau -1)) (sin (+ phi (/ (* 2 pi x) T))))))
|
||||
|
||||
(define result
|
||||
(fit
|
||||
theta
|
||||
((a 40) (tau 15) (phi -0.5) (T 15) (theta0 10))
|
||||
experemental-data))
|
||||
|
||||
|
||||
(plot (mix
|
||||
(points (map vector times vals) (symobol 'square) (color 'black))
|
||||
(error-bars experemental-data)
|
||||
(line (fit-result-function result) (color 'green)))
|
||||
(x-min -5) (x-max 40)
|
||||
(y-min -40) (y-max 50))
|
||||
(fit 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)
|
||||
(error-bars experemental-data)
|
||||
(line (fit-result-function result) #:color 'green))
|
||||
#:x-min -5 #:x-max 40
|
||||
#:y-min -40 #:y-max 50)
|
||||
|
||||
(fit-result-final-params result)
|
||||
;(pretty-print result)
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
shade surface))
|
||||
(only-in "plot.ss"
|
||||
mix
|
||||
derivative gradient make-vec)
|
||||
derivative gradient make-vec
|
||||
mesh3d)
|
||||
(only-in "fit.ss" fit-int))
|
||||
|
||||
(provide plot
|
||||
|
@ -25,7 +26,8 @@
|
|||
mix
|
||||
derivative
|
||||
gradient
|
||||
make-vec)
|
||||
make-vec
|
||||
mesh3d)
|
||||
|
||||
(define-syntax-rule (out-fit-struct)
|
||||
(begin
|
||||
|
@ -50,8 +52,9 @@
|
|||
#:fgcolor [fgcolor '(0 0 0)]
|
||||
#:bgcolor [bgcolor '(255 255 255)]
|
||||
#:lncolor [lncolor '(255 0 0)]
|
||||
#:out-file [out-file #f]
|
||||
arg-extra ...)
|
||||
(orig:plot data
|
||||
(orig:plot data
|
||||
[width width]
|
||||
[height height]
|
||||
[x-min x-min]
|
||||
|
@ -64,16 +67,17 @@
|
|||
[fgcolor fgcolor]
|
||||
[bgcolor bgcolor]
|
||||
[lncolor lncolor]
|
||||
[out-file out-file]
|
||||
init-extra ...)))
|
||||
|
||||
(define-plot plot orig:plot [] [])
|
||||
|
||||
(define-plot plot3d orig:plot3d
|
||||
[#:z-min [z-min -5]
|
||||
#:z-max [z-max 5]
|
||||
#:z-label [z-label "Z axis"]
|
||||
#:alt [alt 30]
|
||||
#:az [az 45]]
|
||||
#:z-max [z-max 5]
|
||||
#:z-label [z-label "Z axis"]
|
||||
#:alt [alt 30]
|
||||
#:az [az 45]]
|
||||
[[z-min z-min]
|
||||
[z-max z-max]
|
||||
[z-label z-label]
|
||||
|
@ -82,8 +86,8 @@
|
|||
|
||||
(define (plot-color? v)
|
||||
(memq v '(white black yellow green aqua pink
|
||||
wheat grey blown blue violet cyan
|
||||
turquoise magenta salmon red)))
|
||||
wheat grey blown blue violet cyan
|
||||
turquoise magenta salmon red)))
|
||||
|
||||
(define (points vecs
|
||||
#:sym [sym 'square]
|
||||
|
@ -114,11 +118,13 @@
|
|||
(define (vector-field f
|
||||
#:width [width 1]
|
||||
#:color [color 'red]
|
||||
#:style [style 'scaled])
|
||||
#:style [style 'scaled]
|
||||
#:samples [samples 20])
|
||||
(orig:vector-field f
|
||||
[width width]
|
||||
[color color]
|
||||
[style style]))
|
||||
[style style]
|
||||
[samples samples]))
|
||||
|
||||
(define (contour f
|
||||
#:samples [samples 50]
|
||||
|
|
|
@ -156,24 +156,23 @@
|
|||
; (begin0
|
||||
; (send bmdc get-bitmap)
|
||||
; (send bmdc set-bitmap #f))))
|
||||
|
||||
|
||||
(super-instantiate ())))
|
||||
|
||||
|
||||
;; a 2d plot view
|
||||
(define 2d-view%
|
||||
(define 2d-view%
|
||||
(class* plot-view% ()
|
||||
(public
|
||||
set-labels
|
||||
(public
|
||||
set-labels
|
||||
plot-y-errors
|
||||
plot-vector
|
||||
plot-vectors
|
||||
plot-vectors
|
||||
plot-points
|
||||
plot-line
|
||||
plot-contours
|
||||
plot-shades
|
||||
fill
|
||||
)
|
||||
|
||||
fill)
|
||||
|
||||
; set-labels : string string string -> nothing
|
||||
; sets the x, y and title lables
|
||||
(define (set-labels x-label y-label title)
|
||||
|
|
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
|
||||
#|
|
||||
exec mred -u "$0" "$@"
|
||||
#| -*- scheme -*-
|
||||
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)
|
||||
(with-input-from-file file (lambda () (read-bytes 100000))))
|
||||
(with-input-from-file file (lambda () (read-bytes (file-size file)))))
|
||||
|
||||
(define-syntax run-test
|
||||
(syntax-rules ()
|
||||
[(_ description (plot args ...) file-name)
|
||||
(let* ([result-file-name (string-append file-name "-out.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.
|
||||
(printf "testing \"~a\" ... " description)
|
||||
(if (equal? (md5 (read-file result-file-name))
|
||||
|
@ -28,72 +23,59 @@ exec mred -u "$0" "$@"
|
|||
expected-file-name
|
||||
result-file-name)))]))
|
||||
|
||||
|
||||
(run-test "Line"
|
||||
(plot
|
||||
(line (lambda (x) x) (color 'red)))
|
||||
(plot (line (lambda (x) x) #:color 'red))
|
||||
"red-identity")
|
||||
|
||||
|
||||
|
||||
(run-test
|
||||
"Vector Field"
|
||||
(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")
|
||||
(run-test "Vector Field"
|
||||
(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")
|
||||
|
||||
(define (trig x y) (* (sin x) (sin y)))
|
||||
|
||||
(run-test
|
||||
"Shading"
|
||||
(plot (shade trig)
|
||||
(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)"))
|
||||
"shade")
|
||||
(run-test "Shading"
|
||||
(plot (shade trig)
|
||||
#: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)")
|
||||
"shade")
|
||||
|
||||
(run-test
|
||||
"Contours"
|
||||
(plot (contour trig)
|
||||
(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)"))
|
||||
"contours")
|
||||
(run-test "Contours"
|
||||
(plot (contour trig)
|
||||
#: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)")
|
||||
"contours")
|
||||
|
||||
(run-test
|
||||
"Mix of all three"
|
||||
(plot (mix
|
||||
(shade trig)
|
||||
(contour trig)
|
||||
(vector-field (gradient trig ) (samples 25)))
|
||||
(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)"))
|
||||
"mix")
|
||||
(run-test "Mix of all three"
|
||||
(plot (mix (shade trig)
|
||||
(contour trig)
|
||||
(vector-field (gradient trig) #:samples 25))
|
||||
#:x-min -1.5 #:x-max 1.5 #:y-min -1.5 #:y-max 1.5
|
||||
#:title "gradient field & shade & contours")
|
||||
"mix")
|
||||
|
||||
(run-test
|
||||
"3d mesg"
|
||||
(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)))
|
||||
"3d-mesh")
|
||||
|
||||
(require mzlib/class
|
||||
(lib "plot-extend.ss" "plot")
|
||||
mzlib/etc)
|
||||
(run-test "3d mesg"
|
||||
(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))
|
||||
"3d-mesh")
|
||||
|
||||
(require plot/plot-extend)
|
||||
|
||||
; (number -> number) mumbo-jumbo -> 2d-renderer
|
||||
(define-plot-type dashed-line
|
||||
fun 2dview (x-min x-max) ((samples 100) (segments 20) (color 'red) (width 1))
|
||||
fun 2dview (x-min x-max) ((samples 100) (segments 20) (color 'red) (width 1))
|
||||
(let* ((dash-size (/ (- x-max x-min) segments))
|
||||
(x-lists (build-list (/ segments 2)
|
||||
(lambda (index)
|
||||
(x-values
|
||||
(/ samples segments)
|
||||
(x-lists (build-list (/ segments 2)
|
||||
(lambda (index)
|
||||
(x-values
|
||||
(/ samples segments)
|
||||
(+ x-min (* 2 index dash-size))
|
||||
(+ x-min (* (add1 ( * 2 index)) dash-size)))))))
|
||||
(send* 2dview
|
||||
(send* 2dview
|
||||
(set-line-color color)
|
||||
(set-line-width width))
|
||||
(for-each (lambda (dash)
|
||||
|
@ -101,14 +83,10 @@ exec mred -u "$0" "$@"
|
|||
(map (lambda (x) (vector x (fun x))) dash)))
|
||||
x-lists)))
|
||||
|
||||
(run-test
|
||||
"Simple plot-extend"
|
||||
(plot (dashed-line (lambda (x) x) (color 'red)))
|
||||
"dashed-line")
|
||||
(run-test "Simple plot-extend"
|
||||
(plot (dashed-line (lambda (x) x) [color 'red]))
|
||||
"dashed-line")
|
||||
|
||||
(run-test
|
||||
"canvas sizing"
|
||||
(plot (line sin) (height 100) (width 100))
|
||||
"size")
|
||||
|
||||
)
|
||||
(run-test "canvas sizing"
|
||||
(plot (line sin) #:height 100 #:width 100)
|
||||
"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 |