plot bug and doc fixes

svn: r9305
This commit is contained in:
Matthew Flatt 2008-04-14 21:53:24 +00:00
parent fbfc9bf883
commit 83ce4d4754
3 changed files with 34 additions and 21 deletions

View File

@ -1,8 +1,19 @@
#lang scheme #lang scheme
(require "plot-extend.ss" (require "plot-extend.ss"
"renderer-helpers.ss"
"view.ss") "view.ss")
(provide (except-out (all-from-out "plot-extend.ss") (provide (except-out (all-from-out "plot-extend.ss")
define-plot-type) define-plot-type)
plot-view%) plot-view%
sample-size
scale-vectors
x-values
normalize-vector
normalize-vectors
make-column
xy-list
zgrid)

View File

@ -5,9 +5,11 @@
plot plot3d plot plot3d
points line error-bars points line error-bars
vector-field contour vector-field contour
shade surface shade surface))
mix fit (only-in "plot.ss"
derivative gradient make-vec))) mix
derivative gradient make-vec)
(only-in "fit.ss" fit-int))
(provide plot (provide plot
plot3d plot3d
@ -19,11 +21,11 @@
contour contour
shade shade
surface surface
(rename-out [orig:mix mix] (rename-out [fit-int fit])
[orig:fit fit] mix
[orig:derivative derivative] derivative
[orig:gradient gradient] gradient
[orig:make-vec make-vec])) make-vec)
(define-syntax-rule (out-fit-struct) (define-syntax-rule (out-fit-struct)
(begin (begin

View File

@ -168,8 +168,8 @@ To fit a particular function to a curve:
@secref["curve-fit"]. @secref["curve-fit"].
@schemeblock[ @schemeblock[
(define fit-result (define fitted
(fir fit-fun (fit fit-fun
'((m 1) (b 1)) '((m 1) (b 1))
data)) data))
] ]
@ -178,10 +178,10 @@ To fit a particular function to a curve:
@item{View the resulting parameters; for example, @item{View the resulting parameters; for example,
@schemeblock[ @schemeblock[
(fit-result-final-params fit-result) (fit-result-final-params fitted)
] ]
will produce @schemeresultfont{((m 2) (b 3))}. will produce @schemeresultfont{(2.0 3.0)}.
} }
@item{For some visual feedback of the fit result, plot the function @item{For some visual feedback of the fit result, plot the function
@ -190,7 +190,7 @@ To fit a particular function to a curve:
@schemeblock[ @schemeblock[
(plot (mix (points data) (plot (mix (points data)
(line (fit-result-function fit-result))) (line (fit-result-function fitted)))
#:y-max 15) #:y-max 15)
] ]
} }
@ -217,7 +217,7 @@ function, we could do the following:
(define (dashed-line fun (define (dashed-line fun
#:x-min [x-min -5] #:x-min [x-min -5]
#:x-max [x-max 5] #:x-max [x-max 5]
#:sample [sample 100] #:samples [samples 100]
#:segments [segments 20] #:segments [segments 20]
#:color [color 'red] #:color [color 'red]
#:width [width 1]) #:width [width 1])
@ -225,7 +225,7 @@ function, we could do the following:
(x-lists (build-list (x-lists (build-list
(/ segments 2) (/ segments 2)
(lambda (index) (lambda (index)
(x-samples (x-values
(/ samples segments) (/ samples segments)
(+ x-min (* 2 index dash-size)) (+ x-min (* 2 index dash-size))
(+ x-min (* (add1 (* 2 index)) (+ x-min (* (add1 (* 2 index))
@ -432,12 +432,12 @@ values. The more accurate your initial guesses are, the more likely
the fit is to succeed; if there are no good values for the guesses, the fit is to succeed; if there are no good values for the guesses,
leave them as @scheme[1].} leave them as @scheme[1].}
@defstruct[fit-result ([rms any/c] @defstruct[fit-result ([rms real?]
[variance any/c] [variance real?]
[names (listof symbol?)] [names (listof symbol?)]
[final-params (listof (cons/c symbol? real?))] [final-params (listof real?)]
[std-error real?] [std-error (listof real?)]
[std-error-percent real?] [std-error-percent (listof real?)]
[function (real? ... . -> . real?)])]{ [function (real? ... . -> . real?)])]{
The @scheme[params] field contains an associative list of the The @scheme[params] field contains an associative list of the