Initial commit for `typed/plot' module
I also made some minor changes to `plot' so that its functions would type more easily. In particular, everything that used to take a list of vectors now accepts a (Sequenceof (Sequenceof Real)). The 3D discrete histogram renderers now also accept lists as well as vectors in the sequence of categories. For now, in typed/plot functions, optional non-keyword arguments are required. As soon as Vincent closes PR 13354, I should be able to uncomment part of a macro in "typed/plot/syntax.rkt" to make them correctly optional.
This commit is contained in:
parent
0b095382ca
commit
5a2aa226fb
|
@ -1503,7 +1503,9 @@ path/s is either such a string or a list of them.
|
|||
"collects/texpict/face-demo.rkt" drdr:command-line (mzc *)
|
||||
"collects/trace" responsible (mflatt robby)
|
||||
"collects/typed" responsible (samth)
|
||||
"collects/typed/plot" responsible (ntoronto)
|
||||
"collects/typed/rackunit" responsible (jay)
|
||||
"collects/typed/tests/typed-plot-tests.rkt" responsible (ntoronto)
|
||||
"collects/typed-racket" responsible (samth stamourv)
|
||||
"collects/typed-racket/base-env/base-special-env.rkt" drdr:command-line (raco "make" *)
|
||||
"collects/typed-racket/optimizer" responsible (stamourv)
|
||||
|
|
|
@ -185,7 +185,7 @@
|
|||
(loop (+ i 2) (cons (string->symbol (substring str i (+ i 2))) fmt-list))]
|
||||
[else (loop (+ i 1) (cons (substring str i (+ i 1)) fmt-list))])))
|
||||
|
||||
(defproc (apply-formatter [formatter (symbol? . -> . (or/c string? #f))]
|
||||
(defproc (apply-formatter [formatter (symbol? any/c . -> . (or/c string? #f))]
|
||||
[fmt-list (listof (or/c string? symbol?))]
|
||||
[d any/c]) (listof string?)
|
||||
(for/list ([fmt (in-list fmt-list)])
|
||||
|
|
|
@ -11,6 +11,15 @@
|
|||
[_ (in-range (- end start))])
|
||||
e))
|
||||
|
||||
(define (sequence-head-vector name xs n)
|
||||
(define vec (for/vector ([x xs] [i (in-range n)]) x))
|
||||
(unless (= n (vector-length vec))
|
||||
(raise-argument-error name (format "sequence of length >= ~a" n) xs))
|
||||
vec)
|
||||
|
||||
(define (sequence->listof-vector name vs n)
|
||||
(map (λ (v) (sequence-head-vector name v n)) (sequence->list vs)))
|
||||
|
||||
(define (list-index v lst [equal? equal?])
|
||||
(for/first ([e (in-list lst)] [i (in-naturals)] #:when (equal? e v))
|
||||
i))
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
empty-ivl unknown-ivl rational-ivl?
|
||||
(activate-contract-out
|
||||
ivl-empty? ivl-known? ivl-rational? ivl-singular? ivl-length ivl-center ivl-zero-length?
|
||||
ivl-inexact->exact ivl-contains? bounds->intervals clamp-real))
|
||||
ivl-inexact->exact ivl-contains? ivl-translate bounds->intervals clamp-real))
|
||||
|
||||
;; Rectangles
|
||||
(provide (contract-out [rect-meet (->* () () #:rest (listof (vectorof ivl?)) (vectorof ivl?))]
|
||||
|
@ -29,4 +29,4 @@
|
|||
(activate-contract-out
|
||||
empty-rect unknown-rect bounding-rect rational-rect?
|
||||
rect-empty? rect-known? rect-rational? rect-area rect-center rect-zero-area? rect-singular?
|
||||
rect-inexact->exact rect-contains?))
|
||||
rect-inexact->exact rect-translate rect-contains?))
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
(require racket/contract racket/class racket/match racket/math racket/list
|
||||
unstable/latent-contract/defthing
|
||||
unstable/contract
|
||||
plot/utils
|
||||
"../common/utils.rkt"
|
||||
"line.rkt"
|
||||
"interval.rkt"
|
||||
"point.rkt"
|
||||
|
@ -222,7 +224,7 @@
|
|||
empty)
|
||||
|
||||
(defproc (point-label
|
||||
[v (vector/c real? real?)] [label (or/c string? #f) #f]
|
||||
[v (sequence/c real?)] [label (or/c string? #f) #f]
|
||||
[#:color color plot-color/c (plot-foreground)]
|
||||
[#:size size (>=/c 0) (plot-font-size)]
|
||||
[#:family family font-family/c (plot-font-family)]
|
||||
|
@ -235,18 +237,18 @@
|
|||
[#:point-sym point-sym point-sym/c 'fullcircle]
|
||||
[#:alpha alpha (real-in 0 1) (label-alpha)]
|
||||
) renderer2d?
|
||||
(match-define (vector x y) v)
|
||||
(renderer2d (vector (ivl x x) (ivl y y)) #f #f
|
||||
(label-render-proc
|
||||
label v color size family anchor angle
|
||||
point-color (cond [(eq? point-fill-color 'auto) (->pen-color point-color)]
|
||||
[else point-fill-color])
|
||||
point-size point-line-width point-sym
|
||||
alpha)))
|
||||
(let ([v (sequence-head-vector 'point-label v 2)])
|
||||
(match-define (vector x y) v)
|
||||
(renderer2d (vector (ivl x x) (ivl y y)) #f #f
|
||||
(label-render-proc
|
||||
label v color size family anchor angle
|
||||
point-color (cond [(eq? point-fill-color 'auto) (->pen-color point-color)]
|
||||
[else point-fill-color])
|
||||
point-size point-line-width point-sym
|
||||
alpha))))
|
||||
|
||||
(defproc (parametric-label
|
||||
[f (real? . -> . (vector/c real? real?))]
|
||||
[t real?] [label (or/c string? #f) #f]
|
||||
[f (real? . -> . (sequence/c real?))] [t real?] [label (or/c string? #f) #f]
|
||||
[#:color color plot-color/c (plot-foreground)]
|
||||
[#:size size (>=/c 0) (plot-font-size)]
|
||||
[#:family family font-family/c (plot-font-family)]
|
||||
|
@ -259,9 +261,7 @@
|
|||
[#:point-sym point-sym point-sym/c 'fullcircle]
|
||||
[#:alpha alpha (real-in 0 1) (label-alpha)]
|
||||
) renderer2d?
|
||||
(point-label (match f
|
||||
[(vector fx fy) (vector (fx t) (fy t))]
|
||||
[(? procedure?) (f t)])
|
||||
(point-label (sequence-head-vector 'parametric-label (f t) 2)
|
||||
label #:color color #:size size #:family family #:anchor anchor #:angle angle
|
||||
#:point-color point-color #:point-fill-color point-fill-color #:point-size point-size
|
||||
#:point-line-width point-line-width #:point-sym point-sym
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
;; Renderers for intervals between functions.
|
||||
|
||||
(require racket/contract racket/class racket/match racket/math racket/list
|
||||
(require racket/contract racket/class racket/match racket/math racket/list racket/sequence
|
||||
unstable/latent-contract/defthing
|
||||
plot/utils)
|
||||
unstable/contract
|
||||
plot/utils
|
||||
"../common/utils.rkt")
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -33,8 +35,8 @@
|
|||
[else empty]))
|
||||
|
||||
(defproc (lines-interval
|
||||
[v1s (listof (vector/c real? real?))]
|
||||
[v2s (listof (vector/c real? real?))]
|
||||
[v1s (sequence/c (sequence/c real?))]
|
||||
[v2s (sequence/c (sequence/c real?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (interval-color)]
|
||||
|
@ -48,24 +50,26 @@
|
|||
[#:alpha alpha (real-in 0 1) (interval-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(define rvs (filter vrational? (append v1s v2s)))
|
||||
(cond
|
||||
[(empty? rvs) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector rxs rys) ...) rvs)
|
||||
(let ([x-min (if x-min x-min (apply min* rxs))]
|
||||
[x-max (if x-max x-max (apply max* rxs))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))])
|
||||
(renderer2d (vector (ivl x-min x-max) (ivl y-min y-max)) #f default-ticks-fun
|
||||
(lines-interval-render-proc v1s v2s color style
|
||||
line1-color line1-width line1-style
|
||||
line2-color line2-width line2-style
|
||||
alpha label)))]))
|
||||
(let ([v1s (sequence->listof-vector 'lines-interval v1s 2)]
|
||||
[v2s (sequence->listof-vector 'lines-interval v2s 2)])
|
||||
(define rvs (filter vrational? (append v1s v2s)))
|
||||
(cond
|
||||
[(empty? rvs) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector rxs rys) ...) rvs)
|
||||
(let ([x-min (if x-min x-min (apply min* rxs))]
|
||||
[x-max (if x-max x-max (apply max* rxs))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))])
|
||||
(renderer2d (vector (ivl x-min x-max) (ivl y-min y-max)) #f default-ticks-fun
|
||||
(lines-interval-render-proc v1s v2s color style
|
||||
line1-color line1-width line1-style
|
||||
line2-color line2-width line2-style
|
||||
alpha label)))])))
|
||||
|
||||
(defproc (parametric-interval
|
||||
[f1 (real? . -> . (vector/c real? real?))]
|
||||
[f2 (real? . -> . (vector/c real? real?))]
|
||||
[f1 (real? . -> . (sequence/c real?))]
|
||||
[f2 (real? . -> . (sequence/c real?))]
|
||||
[t-min rational?] [t-max rational?]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
|
@ -81,14 +85,16 @@
|
|||
[#:alpha alpha (real-in 0 1) (interval-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(lines-interval
|
||||
(map f1 (linear-seq t-min t-max samples))
|
||||
(map f2 (linear-seq t-min t-max samples))
|
||||
#:x-min x-min #:x-max x-max #:y-min y-min #:y-max y-max
|
||||
#:color color #:style style
|
||||
#:line1-color line1-color #:line1-width line1-width #:line1-style line1-style
|
||||
#:line2-color line2-color #:line2-width line2-width #:line2-style line2-style
|
||||
#:alpha alpha #:label label))
|
||||
(let ([f1 (λ (t) (sequence-head-vector 'parametric-interval (f1 t) 2))]
|
||||
[f2 (λ (t) (sequence-head-vector 'parametric-interval (f2 t) 2))])
|
||||
(lines-interval
|
||||
(map f1 (linear-seq t-min t-max samples))
|
||||
(map f2 (linear-seq t-min t-max samples))
|
||||
#:x-min x-min #:x-max x-max #:y-min y-min #:y-max y-max
|
||||
#:color color #:style style
|
||||
#:line1-color line1-color #:line1-width line1-width #:line1-style line1-style
|
||||
#:line2-color line2-color #:line2-width line2-width #:line2-style line2-style
|
||||
#:alpha alpha #:label label)))
|
||||
|
||||
(defproc (polar-interval
|
||||
[f1 (real? . -> . real?)] [f2 (real? . -> . real?)]
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
;; Line renderers.
|
||||
|
||||
(require racket/contract racket/class racket/match racket/math racket/list
|
||||
(require racket/contract racket/class racket/match racket/math racket/list racket/sequence
|
||||
unstable/latent-contract/defthing
|
||||
plot/utils)
|
||||
unstable/contract
|
||||
plot/utils
|
||||
"../common/utils.rkt")
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -19,7 +21,7 @@
|
|||
(cond [label (line-legend-entry label color width style)]
|
||||
[else empty]))
|
||||
|
||||
(defproc (lines [vs (listof (vector/c real? real?))]
|
||||
(defproc (lines [vs (sequence/c (sequence/c real?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
|
@ -28,18 +30,19 @@
|
|||
[#:alpha alpha (real-in 0 1) (line-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(define rvs (filter vrational? vs))
|
||||
(cond [(empty? rvs) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector rxs rys) ...) rvs)
|
||||
(let ([x-min (if x-min x-min (apply min* rxs))]
|
||||
[x-max (if x-max x-max (apply max* rxs))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))])
|
||||
(renderer2d (vector (ivl x-min x-max) (ivl y-min y-max)) #f default-ticks-fun
|
||||
(lines-render-proc vs color width style alpha label)))]))
|
||||
(let ([vs (sequence->listof-vector 'lines vs 2)])
|
||||
(define rvs (filter vrational? vs))
|
||||
(cond [(empty? rvs) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector rxs rys) ...) rvs)
|
||||
(let ([x-min (if x-min x-min (apply min* rxs))]
|
||||
[x-max (if x-max x-max (apply max* rxs))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))])
|
||||
(renderer2d (vector (ivl x-min x-max) (ivl y-min y-max)) #f default-ticks-fun
|
||||
(lines-render-proc vs color width style alpha label)))])))
|
||||
|
||||
(defproc (parametric [f (real? . -> . (vector/c real? real?))]
|
||||
(defproc (parametric [f (real? . -> . (sequence/c real?))]
|
||||
[t-min rational?] [t-max rational?]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
|
@ -50,10 +53,11 @@
|
|||
[#:alpha alpha (real-in 0 1) (line-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(lines (map f (linear-seq t-min t-max samples))
|
||||
#:x-min x-min #:x-max x-max #:y-min y-min #:y-max y-max
|
||||
#:color color #:width width #:style style #:alpha alpha
|
||||
#:label label))
|
||||
(let ([f (λ (t) (sequence-head-vector 'parametric (f t) 2))])
|
||||
(lines (map f (linear-seq t-min t-max samples))
|
||||
#:x-min x-min #:x-max x-max #:y-min y-min #:y-max y-max
|
||||
#:color color #:width width #:style style #:alpha alpha
|
||||
#:label label)))
|
||||
|
||||
(defproc (polar [f (real? . -> . real?)]
|
||||
[θ-min real? 0] [θ-max real? (* 2 pi)]
|
||||
|
@ -139,7 +143,7 @@
|
|||
;; ===================================================================================================
|
||||
;; Kernel density estimation
|
||||
|
||||
(defproc (density [xs (listof real?)] [bw-adjust real? 1]
|
||||
(defproc (density [xs (sequence/c real?)] [bw-adjust real? 1]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
|
@ -149,11 +153,12 @@
|
|||
[#:alpha alpha (real-in 0 1) (line-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(define n (length xs))
|
||||
(define sd (sqrt (- (/ (sum sqr xs) n) (sqr (/ (sum values xs) n)))))
|
||||
(define h (* bw-adjust 1.06 sd (expt n -0.2)))
|
||||
(define-values (f fx-min fx-max) (kde xs h))
|
||||
(let ([x-min (if x-min x-min fx-min)]
|
||||
[x-max (if x-max x-max fx-max)])
|
||||
(function f x-min x-max #:y-min y-min #:y-max y-max #:samples samples
|
||||
#:color color #:width width #:style style #:alpha alpha #:label label)))
|
||||
(let ([xs (sequence->list xs)])
|
||||
(define n (length xs))
|
||||
(define sd (sqrt (- (/ (sum sqr xs) n) (sqr (/ (sum values xs) n)))))
|
||||
(define h (* bw-adjust 1.06 sd (expt n -0.2)))
|
||||
(define-values (f fx-min fx-max) (kde xs h))
|
||||
(let ([x-min (if x-min x-min fx-min)]
|
||||
[x-max (if x-max x-max fx-max)])
|
||||
(function f x-min x-max #:y-min y-min #:y-max y-max #:samples samples
|
||||
#:color color #:width width #:style style #:alpha alpha #:label label))))
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
;; Renderers for points and other point-like things.
|
||||
|
||||
(require racket/contract racket/class racket/match racket/math racket/list
|
||||
(require racket/contract racket/class racket/match racket/math racket/list racket/sequence
|
||||
unstable/latent-contract/defthing
|
||||
plot/utils)
|
||||
unstable/contract
|
||||
plot/utils
|
||||
"../common/utils.rkt")
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -19,7 +21,7 @@
|
|||
|
||||
(if label (point-legend-entry label sym color fill-color size line-width) empty))
|
||||
|
||||
(defproc (points [vs (listof (vector/c real? real?))]
|
||||
(defproc (points [vs (sequence/c (sequence/c real?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:sym sym point-sym/c (point-sym)]
|
||||
|
@ -30,7 +32,8 @@
|
|||
[#:alpha alpha (real-in 0 1) (point-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(let ([vs (filter vrational? vs)])
|
||||
(let* ([vs (sequence->listof-vector 'points vs 2)]
|
||||
[vs (filter vrational? vs)])
|
||||
(cond
|
||||
[(empty? vs) (renderer2d #f #f #f #f)]
|
||||
[else (match-define (list (vector xs ys) ...) vs)
|
||||
|
@ -89,8 +92,8 @@
|
|||
[else empty])]))
|
||||
|
||||
(defproc (vector-field
|
||||
[f (or/c (real? real? . -> . (vector/c real? real?))
|
||||
((vector/c real? real?) . -> . (vector/c real? real?)))]
|
||||
[f (or/c (real? real? . -> . (sequence/c real?))
|
||||
((vector/c real? real?) . -> . (sequence/c real?)))]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:samples samples exact-positive-integer? (vector-field-samples)]
|
||||
|
@ -101,8 +104,10 @@
|
|||
[#:alpha alpha (real-in 0 1) (vector-field-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(let ([f (cond [(procedure-arity-includes? f 2 #t) f]
|
||||
[else (λ (x y) (f (vector x y)))])])
|
||||
(let ([f (cond [(procedure-arity-includes? f 2 #t)
|
||||
(λ (x y) (sequence-head-vector 'vector-field (f x y) 2))]
|
||||
[else
|
||||
(λ (x y) (sequence-head-vector 'vector-field (f (vector x y)) 2))])])
|
||||
(renderer2d (vector (ivl x-min x-max) (ivl y-min y-max)) #f default-ticks-fun
|
||||
(vector-field-render-fun f samples scale color line-width line-style alpha label))))
|
||||
|
||||
|
@ -126,7 +131,7 @@
|
|||
empty)
|
||||
|
||||
(defproc (error-bars
|
||||
[bars (listof (vector/c real? real? real?))]
|
||||
[bars (sequence/c (sequence/c real?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (error-bar-color)]
|
||||
|
@ -135,7 +140,8 @@
|
|||
[#:width width (>=/c 0) (error-bar-width)]
|
||||
[#:alpha alpha (real-in 0 1) (error-bar-alpha)]
|
||||
) renderer2d?
|
||||
(let ([bars (filter vrational? bars)])
|
||||
(let* ([bars (sequence->listof-vector 'error-bars bars 3)]
|
||||
[bars (filter vrational? bars)])
|
||||
(cond [(empty? bars) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector xs ys hs) ...) bars)
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
;; The histogram renderer.
|
||||
|
||||
(require racket/match racket/contract racket/class racket/list
|
||||
(require racket/match racket/contract racket/class racket/list racket/sequence
|
||||
unstable/latent-contract/defthing
|
||||
unstable/contract
|
||||
plot/utils
|
||||
"../common/utils.rkt")
|
||||
|
||||
|
@ -24,7 +25,7 @@
|
|||
[else empty]))
|
||||
|
||||
(defproc (rectangles
|
||||
[rects (listof (vector/c ivl? ivl?))]
|
||||
[rects (sequence/c (sequence/c ivl?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (rectangle-color)]
|
||||
|
@ -35,26 +36,27 @@
|
|||
[#:alpha alpha (real-in 0 1) (rectangle-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(match-define (list (vector (ivl x1s x2s) (ivl y1s y2s)) ...) rects)
|
||||
(define rxs (filter rational? (append x1s x2s)))
|
||||
(define rys (filter rational? (append y1s y2s)))
|
||||
(cond
|
||||
[(or (empty? rxs) (empty? rys)) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(let ([x-min (if x-min x-min (apply min* rxs))]
|
||||
[x-max (if x-max x-max (apply max* rxs))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))])
|
||||
(renderer2d (vector (ivl x-min x-max) (ivl y-min y-max)) #f default-ticks-fun
|
||||
(rectangles-render-proc rects color style line-color line-width line-style alpha
|
||||
label)))]))
|
||||
(let ([rects (sequence->listof-vector 'rectangles rects 2)])
|
||||
(match-define (list (vector (ivl x1s x2s) (ivl y1s y2s)) ...) rects)
|
||||
(define rxs (filter rational? (append x1s x2s)))
|
||||
(define rys (filter rational? (append y1s y2s)))
|
||||
(cond
|
||||
[(or (empty? rxs) (empty? rys)) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(let ([x-min (if x-min x-min (apply min* rxs))]
|
||||
[x-max (if x-max x-max (apply max* rxs))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))])
|
||||
(renderer2d (vector (ivl x-min x-max) (ivl y-min y-max)) #f default-ticks-fun
|
||||
(rectangles-render-proc rects color style line-color line-width line-style alpha
|
||||
label)))])))
|
||||
|
||||
;; ===================================================================================================
|
||||
;; Real histograms (or histograms on the real line)
|
||||
|
||||
(defproc (area-histogram
|
||||
[f (real? . -> . real?)]
|
||||
[bin-bounds (listof real?)]
|
||||
[bin-bounds (sequence/c real?)]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
|
@ -66,7 +68,8 @@
|
|||
[#:alpha alpha (real-in 0 1) (rectangle-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(let* ([bin-bounds (filter rational? bin-bounds)]
|
||||
(let* ([bin-bounds (sequence->list bin-bounds)]
|
||||
[bin-bounds (filter rational? bin-bounds)]
|
||||
[bin-bounds (sort bin-bounds <)])
|
||||
(cond
|
||||
[((length bin-bounds) . < . 2) (renderer2d #f #f #f #f)]
|
||||
|
@ -81,7 +84,8 @@
|
|||
(define ys (map f xs))
|
||||
(/ (apply + ys) (length xs))))
|
||||
(rectangles (map (λ (x-ivl h) (vector x-ivl (ivl 0 h)))
|
||||
(bounds->intervals bin-bounds) heights)
|
||||
(bounds->intervals bin-bounds)
|
||||
heights)
|
||||
#:x-min x-min #:x-max x-max #:y-min y-min #:y-max y-max
|
||||
#:color color #:style style #:line-color line-color #:line-width line-width
|
||||
#:line-style line-style #:alpha alpha #:label label)])))
|
||||
|
@ -106,8 +110,8 @@
|
|||
(values x-ticks x-far-ticks y-ticks y-far-ticks)))
|
||||
|
||||
(defproc (discrete-histogram
|
||||
[cat-vals (listof (or/c (vector/c any/c (or/c real? ivl? #f))
|
||||
(list/c any/c (or/c real? ivl? #f))))]
|
||||
[cat-vals (sequence/c (or/c (vector/c any/c (or/c real? ivl? #f))
|
||||
(list/c any/c (or/c real? ivl? #f))))]
|
||||
[#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:gap gap (real-in 0 1) (discrete-histogram-gap)]
|
||||
|
@ -123,34 +127,35 @@
|
|||
[#:add-ticks? add-ticks? boolean? #t]
|
||||
[#:far-ticks? far-ticks? boolean? #f]
|
||||
) renderer2d?
|
||||
(match-define (list (or (vector cats ys) (list cats ys)) ...) cat-vals)
|
||||
(define rys (filter rational? (append* (for/list ([y (in-list ys)])
|
||||
(match y
|
||||
[(ivl y1 y2) (list y1 y2)]
|
||||
[_ (list y)])))))
|
||||
(cond
|
||||
[(empty? rys) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(define n (length cats))
|
||||
(let* ([x-min (if x-min x-min 0)]
|
||||
[x-max (if x-max x-max (max x-min (+ x-min (* (- n 1) skip) 1)))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))])
|
||||
(define xs (build-list n (λ (i) (+ x-min (* i skip)))))
|
||||
(define x-ivls (for/list ([x (in-list xs)])
|
||||
(ivl (+ x (* 1/2 gap)) (- (+ x 1) (* 1/2 gap)))))
|
||||
(define tick-xs (for/list ([x (in-list xs)]) (+ x 1/2)))
|
||||
(define y-ivls (map (λ (y) (if (ivl? y) y (ivl 0 y))) ys))
|
||||
(define maybe-invert (if invert? (λ (x y) (vector y x)) vector))
|
||||
(renderer2d
|
||||
(maybe-invert (ivl x-min x-max) (ivl y-min y-max)) #f
|
||||
(discrete-histogram-ticks-fun cats tick-xs add-ticks? far-ticks? maybe-invert)
|
||||
(rectangles-render-proc (map maybe-invert x-ivls y-ivls)
|
||||
color style line-color line-width line-style alpha label)))]))
|
||||
(let ([cat-vals (sequence->list cat-vals)])
|
||||
(match-define (list (or (vector cats ys) (list cats ys)) ...) cat-vals)
|
||||
(define rys (filter rational? (append* (for/list ([y (in-list ys)])
|
||||
(match y
|
||||
[(ivl y1 y2) (list y1 y2)]
|
||||
[_ (list y)])))))
|
||||
(cond
|
||||
[(empty? rys) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(define n (length cats))
|
||||
(let* ([x-min (if x-min x-min 0)]
|
||||
[x-max (if x-max x-max (max x-min (+ x-min (* (- n 1) skip) 1)))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))])
|
||||
(define xs (build-list n (λ (i) (+ x-min (* i skip)))))
|
||||
(define x-ivls (for/list ([x (in-list xs)])
|
||||
(ivl (+ x (* 1/2 gap)) (- (+ x 1) (* 1/2 gap)))))
|
||||
(define tick-xs (for/list ([x (in-list xs)]) (+ x 1/2)))
|
||||
(define y-ivls (map (λ (y) (if (ivl? y) y (ivl 0 y))) ys))
|
||||
(define maybe-invert (if invert? (λ (x y) (vector y x)) vector))
|
||||
(renderer2d
|
||||
(maybe-invert (ivl x-min x-max) (ivl y-min y-max)) #f
|
||||
(discrete-histogram-ticks-fun cats tick-xs add-ticks? far-ticks? maybe-invert)
|
||||
(rectangles-render-proc (map maybe-invert x-ivls y-ivls)
|
||||
color style line-color line-width line-style alpha label)))])))
|
||||
|
||||
(defproc (stacked-histogram
|
||||
[cat-vals (listof (or/c (vector/c any/c (listof real?))
|
||||
(list/c any/c (listof real?))))]
|
||||
[cat-vals (sequence/c (or/c (vector/c any/c (sequence/c real?))
|
||||
(list/c any/c (sequence/c real?))))]
|
||||
[#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:gap gap (real-in 0 1) (discrete-histogram-gap)]
|
||||
|
@ -166,24 +171,26 @@
|
|||
[#:add-ticks? add-ticks? boolean? #t]
|
||||
[#:far-ticks? far-ticks? boolean? #f]
|
||||
) (listof renderer2d?)
|
||||
(match-define (list (or (vector cats ys) (list cats ys)) ...) cat-vals)
|
||||
(define yss (map cumulative-sum ys))
|
||||
(define y-ivlss (for/list ([ys (in-list yss)])
|
||||
(for/list ([y1 (in-list ys)] [y2 (in-list (rest ys))])
|
||||
(ivl y1 y2))))
|
||||
(define max-num (apply max (map length yss)))
|
||||
(for/list ([y-ivls (in-list (transpose y-ivlss))]
|
||||
[color (in-cycle (maybe-apply colors max-num))]
|
||||
[style (in-cycle (maybe-apply styles max-num))]
|
||||
[line-color (in-cycle (maybe-apply line-colors max-num))]
|
||||
[line-width (in-cycle (maybe-apply line-widths max-num))]
|
||||
[line-style (in-cycle (maybe-apply line-styles max-num))]
|
||||
[alpha (in-cycle (maybe-apply alphas max-num))]
|
||||
[label (in-cycle (maybe-apply labels max-num))])
|
||||
(discrete-histogram
|
||||
(map vector cats y-ivls)
|
||||
#:x-min x-min #:x-max x-max #:y-min y-min #:y-max y-max
|
||||
#:gap gap #:skip skip #:invert? invert?
|
||||
#:color color #:style style #:line-color line-color #:line-width line-width
|
||||
#:line-style line-style #:alpha alpha #:label label
|
||||
#:add-ticks? add-ticks? #:far-ticks? far-ticks?)))
|
||||
(let ([cat-vals (sequence->list cat-vals)])
|
||||
(match-define (list (or (vector cats ys) (list cats ys)) ...) cat-vals)
|
||||
(let ([ys (map sequence->list ys)])
|
||||
(define yss (map cumulative-sum ys))
|
||||
(define y-ivlss (for/list ([ys (in-list yss)])
|
||||
(for/list ([y1 (in-list ys)] [y2 (in-list (rest ys))])
|
||||
(ivl y1 y2))))
|
||||
(define max-num (apply max (map length yss)))
|
||||
(for/list ([y-ivls (in-list (transpose y-ivlss))]
|
||||
[color (in-cycle (maybe-apply colors max-num))]
|
||||
[style (in-cycle (maybe-apply styles max-num))]
|
||||
[line-color (in-cycle (maybe-apply line-colors max-num))]
|
||||
[line-width (in-cycle (maybe-apply line-widths max-num))]
|
||||
[line-style (in-cycle (maybe-apply line-styles max-num))]
|
||||
[alpha (in-cycle (maybe-apply alphas max-num))]
|
||||
[label (in-cycle (maybe-apply labels max-num))])
|
||||
(discrete-histogram
|
||||
(map vector cats y-ivls)
|
||||
#:x-min x-min #:x-max x-max #:y-min y-min #:y-max y-max
|
||||
#:gap gap #:skip skip #:invert? invert?
|
||||
#:color color #:style style #:line-color line-color #:line-width line-width
|
||||
#:line-style line-style #:alpha alpha #:label label
|
||||
#:add-ticks? add-ticks? #:far-ticks? far-ticks?)))))
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/class racket/match racket/list racket/contract unstable/latent-contract/defthing
|
||||
plot/utils)
|
||||
(require racket/class racket/match racket/list racket/contract
|
||||
unstable/latent-contract/defthing
|
||||
unstable/contract
|
||||
plot/utils
|
||||
"../common/utils.rkt")
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -32,7 +35,7 @@
|
|||
(lines3d-render-proc vs-thnk color width style alpha label)))]))
|
||||
|
||||
(defproc (lines3d
|
||||
[vs (listof (vector/c real? real? real?))]
|
||||
[vs (sequence/c (sequence/c real?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
|
@ -42,10 +45,11 @@
|
|||
[#:alpha alpha (real-in 0 1) (line-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer3d?
|
||||
(lines3d-renderer (λ () vs) x-min x-max y-min y-max z-min z-max color width style alpha label))
|
||||
(let ([vs (sequence->listof-vector 'lines3d vs 3)])
|
||||
(lines3d-renderer (λ () vs) x-min x-max y-min y-max z-min z-max color width style alpha label)))
|
||||
|
||||
(defproc (parametric3d
|
||||
[f (real? . -> . (vector/c real? real? real?))]
|
||||
[f (real? . -> . (sequence/c real?))]
|
||||
[t-min rational?] [t-max rational?]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
|
@ -57,5 +61,6 @@
|
|||
[#:alpha alpha (real-in 0 1) (line-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer3d?
|
||||
(lines3d-renderer (λ () (map f (linear-seq t-min t-max (animated-samples samples))))
|
||||
x-min x-max y-min y-max z-min z-max color width style alpha label))
|
||||
(let ([f (λ (t) (sequence-head-vector 'parametric3d (f t) 3))])
|
||||
(lines3d-renderer (λ () (map f (linear-seq t-min t-max (animated-samples samples))))
|
||||
x-min x-max y-min y-max z-min z-max color width style alpha label)))
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/class racket/list racket/match racket/contract unstable/latent-contract/defthing
|
||||
plot/utils)
|
||||
(require racket/class racket/list racket/match racket/contract
|
||||
unstable/latent-contract/defthing
|
||||
unstable/contract
|
||||
plot/utils
|
||||
"../common/utils.rkt")
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -17,7 +20,7 @@
|
|||
[else empty]))
|
||||
|
||||
(defproc (points3d
|
||||
[vs (listof (vector/c real? real? real?))]
|
||||
[vs (sequence/c (sequence/c real?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
|
@ -29,7 +32,8 @@
|
|||
[#:alpha alpha (real-in 0 1) (point-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer3d?
|
||||
(let ([vs (filter vrational? vs)])
|
||||
(let* ([vs (sequence->listof-vector 'points3d vs 3)]
|
||||
[vs (filter vrational? vs)])
|
||||
(cond [(empty? vs) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector xs ys zs) ...) vs)
|
||||
|
@ -92,9 +96,8 @@
|
|||
[else empty])]))
|
||||
|
||||
(defproc (vector-field3d
|
||||
[f (or/c (real? real? real? . -> . (vector/c real? real? real?))
|
||||
((vector/c real? real? real?)
|
||||
. -> . (vector/c real? real? real?)))]
|
||||
[f (or/c (real? real? real? . -> . (sequence/c real?))
|
||||
((vector/c real? real? real?) . -> . (sequence/c real?)))]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[z-min (or/c rational? #f) #f] [z-max (or/c rational? #f) #f]
|
||||
|
@ -106,7 +109,9 @@
|
|||
[#:alpha alpha (real-in 0 1) (vector-field-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer3d?
|
||||
(let ([f (cond [(procedure-arity-includes? f 3 #t) f]
|
||||
[else (λ (x y z) (f (vector x y z)))])])
|
||||
(let ([f (cond [(procedure-arity-includes? f 3 #t)
|
||||
(λ (x y z) (sequence-head-vector 'vector-field3d (f x y z) 3))]
|
||||
[else
|
||||
(λ (x y z) (sequence-head-vector 'vector-field3d (f (vector x y z)) 3))])])
|
||||
(renderer3d (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f default-ticks-fun
|
||||
(vector-field3d-render-fun f samples scale color line-width line-style alpha label))))
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
;; Functions to create renderers for 3D histograms
|
||||
|
||||
(require racket/match racket/list racket/contract racket/class unstable/latent-contract/defthing
|
||||
(require racket/match racket/list racket/contract racket/class racket/sequence
|
||||
unstable/latent-contract/defthing
|
||||
unstable/contract
|
||||
plot/utils
|
||||
"../common/utils.rkt")
|
||||
|
||||
|
@ -23,7 +25,7 @@
|
|||
[else empty]))
|
||||
|
||||
(defproc (rectangles3d
|
||||
[rects (listof (vector/c ivl? ivl? ivl?))]
|
||||
[rects (sequence/c (sequence/c ivl?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
|
@ -35,23 +37,24 @@
|
|||
[#:alpha alpha (real-in 0 1) (rectangle-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer3d?
|
||||
(match-define (list (vector (ivl x1s x2s) (ivl y1s y2s) (ivl z1s z2s)) ...) rects)
|
||||
(define rxs (filter rational? (append x1s x2s)))
|
||||
(define rys (filter rational? (append y1s y2s)))
|
||||
(define rzs (filter rational? (append z1s z2s)))
|
||||
(cond
|
||||
[(or (empty? rxs) (empty? rys) (empty? rzs)) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
(let ([x-min (if x-min x-min (apply min* rxs))]
|
||||
[x-max (if x-max x-max (apply max* rxs))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))]
|
||||
[z-min (if z-min z-min (apply min* rzs))]
|
||||
[z-max (if z-max z-max (apply max* rzs))])
|
||||
(renderer3d (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f
|
||||
default-ticks-fun
|
||||
(rectangles3d-render-proc rects color style line-color line-width line-style
|
||||
alpha label)))]))
|
||||
(let ([rects (sequence->listof-vector 'rectangles3d rects 3)])
|
||||
(match-define (list (vector (ivl x1s x2s) (ivl y1s y2s) (ivl z1s z2s)) ...) rects)
|
||||
(define rxs (filter rational? (append x1s x2s)))
|
||||
(define rys (filter rational? (append y1s y2s)))
|
||||
(define rzs (filter rational? (append z1s z2s)))
|
||||
(cond
|
||||
[(or (empty? rxs) (empty? rys) (empty? rzs)) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
(let ([x-min (if x-min x-min (apply min* rxs))]
|
||||
[x-max (if x-max x-max (apply max* rxs))]
|
||||
[y-min (if y-min y-min (apply min* rys))]
|
||||
[y-max (if y-max y-max (apply max* rys))]
|
||||
[z-min (if z-min z-min (apply min* rzs))]
|
||||
[z-max (if z-max z-max (apply max* rzs))])
|
||||
(renderer3d (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f
|
||||
default-ticks-fun
|
||||
(rectangles3d-render-proc rects color style line-color line-width line-style
|
||||
alpha label)))])))
|
||||
|
||||
;; ===================================================================================================
|
||||
;; Discrete histograms
|
||||
|
@ -79,7 +82,8 @@
|
|||
(ivl (+ x1 1/2-gap-size) (- x2 1/2-gap-size)))
|
||||
|
||||
(defproc (discrete-histogram3d
|
||||
[cat-vals (listof (vector/c any/c any/c (or/c real? ivl? #f)))]
|
||||
[cat-vals (sequence/c (or/c (vector/c any/c any/c (or/c real? ivl? #f))
|
||||
(list/c any/c any/c (or/c real? ivl? #f))))]
|
||||
[#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) 0] [#:z-max z-max (or/c rational? #f) #f]
|
||||
|
@ -96,53 +100,55 @@
|
|||
[#:x-far-ticks? x-far-ticks? boolean? #f]
|
||||
[#:y-far-ticks? y-far-ticks? boolean? #f]
|
||||
) renderer3d?
|
||||
(match-define (list (vector cat1s cat2s zs) ...) cat-vals)
|
||||
(define rzs (filter rational? (append* (for/list ([z (in-list zs)])
|
||||
(match z
|
||||
[(ivl z1 z2) (list z1 z2)]
|
||||
[_ (list z)])))))
|
||||
(cond
|
||||
[(empty? rzs) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
(define c1s (remove-duplicates cat1s))
|
||||
(define c2s (remove-duplicates cat2s))
|
||||
(define x-num (length c1s))
|
||||
(define y-num (length c2s))
|
||||
(let* ([x-min (if x-min x-min 0)]
|
||||
[x-max (if x-max x-max (+ x-min x-num))]
|
||||
[y-min (if y-min y-min 0)]
|
||||
[y-max (if y-max y-max (+ y-min y-num))]
|
||||
[z-min (if z-min z-min (apply min* rzs))]
|
||||
[z-max (if z-max z-max (apply max* rzs))])
|
||||
(define xs (linear-seq x-min x-max (add1 x-num)))
|
||||
(define ys (linear-seq y-min y-max (add1 y-num)))
|
||||
(define h (make-hash (for/list ([c1 (in-list cat1s)] [c2 (in-list cat2s)] [z (in-list zs)])
|
||||
(cons (cons c1 c2) z))))
|
||||
(match-define (list (vector x1s x2s y1s y2s all-zs) ...)
|
||||
(for/list ([y1 (in-list ys)]
|
||||
[y2 (in-list (rest ys))]
|
||||
[c2 (in-list c2s)]
|
||||
#:when #t
|
||||
[x1 (in-list xs)]
|
||||
[x2 (in-list (rest xs))]
|
||||
[c1 (in-list c1s)])
|
||||
(vector x1 x2 y1 y2 (hash-ref h (cons c1 c2) +nan.0))))
|
||||
(define tick-xs (linear-seq x-min x-max x-num #:start? #f #:end? #f))
|
||||
(define tick-ys (linear-seq y-min y-max y-num #:start? #f #:end? #f))
|
||||
(define rects (map (λ (x1 x2 y1 y2 z)
|
||||
(vector (adjust/gap (ivl x1 x2) gap)
|
||||
(adjust/gap (ivl y1 y2) gap)
|
||||
(if (ivl? z) z (ivl 0 z))))
|
||||
x1s x2s y1s y2s all-zs))
|
||||
(renderer3d
|
||||
(vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f
|
||||
(discrete-histogram3d-ticks-fun c1s c2s tick-xs tick-ys
|
||||
add-x-ticks? add-y-ticks? x-far-ticks? y-far-ticks?)
|
||||
(rectangles3d-render-proc rects color style line-color line-width line-style
|
||||
alpha label)))]))
|
||||
(let ([cat-vals (sequence->list cat-vals)])
|
||||
(match-define (list (or (vector cat1s cat2s zs) (list cat1s cat2s zs)) ...) cat-vals)
|
||||
(define rzs (filter rational? (append* (for/list ([z (in-list zs)])
|
||||
(match z
|
||||
[(ivl z1 z2) (list z1 z2)]
|
||||
[_ (list z)])))))
|
||||
(cond
|
||||
[(empty? rzs) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
(define c1s (remove-duplicates cat1s))
|
||||
(define c2s (remove-duplicates cat2s))
|
||||
(define x-num (length c1s))
|
||||
(define y-num (length c2s))
|
||||
(let* ([x-min (if x-min x-min 0)]
|
||||
[x-max (if x-max x-max (+ x-min x-num))]
|
||||
[y-min (if y-min y-min 0)]
|
||||
[y-max (if y-max y-max (+ y-min y-num))]
|
||||
[z-min (if z-min z-min (apply min* rzs))]
|
||||
[z-max (if z-max z-max (apply max* rzs))])
|
||||
(define xs (linear-seq x-min x-max (add1 x-num)))
|
||||
(define ys (linear-seq y-min y-max (add1 y-num)))
|
||||
(define h (make-hash (for/list ([c1 (in-list cat1s)] [c2 (in-list cat2s)] [z (in-list zs)])
|
||||
(cons (cons c1 c2) z))))
|
||||
(match-define (list (vector x1s x2s y1s y2s all-zs) ...)
|
||||
(for/list ([y1 (in-list ys)]
|
||||
[y2 (in-list (rest ys))]
|
||||
[c2 (in-list c2s)]
|
||||
#:when #t
|
||||
[x1 (in-list xs)]
|
||||
[x2 (in-list (rest xs))]
|
||||
[c1 (in-list c1s)])
|
||||
(vector x1 x2 y1 y2 (hash-ref h (cons c1 c2) +nan.0))))
|
||||
(define tick-xs (linear-seq x-min x-max x-num #:start? #f #:end? #f))
|
||||
(define tick-ys (linear-seq y-min y-max y-num #:start? #f #:end? #f))
|
||||
(define rects (map (λ (x1 x2 y1 y2 z)
|
||||
(vector (adjust/gap (ivl x1 x2) gap)
|
||||
(adjust/gap (ivl y1 y2) gap)
|
||||
(if (ivl? z) z (ivl 0 z))))
|
||||
x1s x2s y1s y2s all-zs))
|
||||
(renderer3d
|
||||
(vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f
|
||||
(discrete-histogram3d-ticks-fun c1s c2s tick-xs tick-ys
|
||||
add-x-ticks? add-y-ticks? x-far-ticks? y-far-ticks?)
|
||||
(rectangles3d-render-proc rects color style line-color line-width line-style
|
||||
alpha label)))])))
|
||||
|
||||
(defproc (stacked-histogram3d
|
||||
[cat-vals (listof (vector/c any/c any/c (listof real?)))]
|
||||
[cat-vals (sequence/c (or/c (vector/c any/c any/c (sequence/c real?))
|
||||
(list/c any/c any/c (sequence/c real?))))]
|
||||
[#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) 0] [#:z-max z-max (or/c rational? #f) #f]
|
||||
|
@ -159,24 +165,26 @@
|
|||
[#:x-far-ticks? x-far-ticks? boolean? #f]
|
||||
[#:y-far-ticks? y-far-ticks? boolean? #f]
|
||||
) (listof renderer3d?)
|
||||
(match-define (list (vector cat1s cat2s zs) ...) cat-vals)
|
||||
(define zss (map cumulative-sum zs))
|
||||
(define z-ivlss (for/list ([zs (in-list zss)])
|
||||
(for/list ([z1 (in-list zs)] [z2 (in-list (rest zs))])
|
||||
(ivl z1 z2))))
|
||||
(define max-num (apply max (map length zss)))
|
||||
(for/list ([z-ivls (in-list (transpose z-ivlss))]
|
||||
[color (in-cycle (maybe-apply colors max-num))]
|
||||
[style (in-cycle (maybe-apply styles max-num))]
|
||||
[line-color (in-cycle (maybe-apply line-colors max-num))]
|
||||
[line-width (in-cycle (maybe-apply line-widths max-num))]
|
||||
[line-style (in-cycle (maybe-apply line-styles max-num))]
|
||||
[alpha (in-cycle (maybe-apply alphas max-num))]
|
||||
[label (in-cycle (maybe-apply labels max-num))])
|
||||
(discrete-histogram3d
|
||||
(map vector cat1s cat2s z-ivls)
|
||||
#:x-min x-min #:x-max x-max #:y-min y-min #:y-max y-max #:z-min z-min #:z-max z-max #:gap gap
|
||||
#:color color #:style style #:line-color line-color #:line-width line-width
|
||||
#:line-style line-style #:alpha alpha #:label label
|
||||
#:add-x-ticks? add-x-ticks? #:add-y-ticks? add-y-ticks?
|
||||
#:x-far-ticks? x-far-ticks? #:y-far-ticks? y-far-ticks?)))
|
||||
(let ([cat-vals (sequence->list cat-vals)])
|
||||
(match-define (list (or (vector cat1s cat2s zs) (list cat1s cat2s zs)) ...) cat-vals)
|
||||
(let ([zs (map sequence->list zs)])
|
||||
(define zss (map cumulative-sum zs))
|
||||
(define z-ivlss (for/list ([zs (in-list zss)])
|
||||
(for/list ([z1 (in-list zs)] [z2 (in-list (rest zs))])
|
||||
(ivl z1 z2))))
|
||||
(define max-num (apply max (map length zss)))
|
||||
(for/list ([z-ivls (in-list (transpose z-ivlss))]
|
||||
[color (in-cycle (maybe-apply colors max-num))]
|
||||
[style (in-cycle (maybe-apply styles max-num))]
|
||||
[line-color (in-cycle (maybe-apply line-colors max-num))]
|
||||
[line-width (in-cycle (maybe-apply line-widths max-num))]
|
||||
[line-style (in-cycle (maybe-apply line-styles max-num))]
|
||||
[alpha (in-cycle (maybe-apply alphas max-num))]
|
||||
[label (in-cycle (maybe-apply labels max-num))])
|
||||
(discrete-histogram3d
|
||||
(map vector cat1s cat2s z-ivls)
|
||||
#:x-min x-min #:x-max x-max #:y-min y-min #:y-max y-max #:z-min z-min #:z-max z-max #:gap gap
|
||||
#:color color #:style style #:line-color line-color #:line-width line-width
|
||||
#:line-style line-style #:alpha alpha #:label label
|
||||
#:add-x-ticks? add-x-ticks? #:add-y-ticks? add-y-ticks?
|
||||
#:x-far-ticks? x-far-ticks? #:y-far-ticks? y-far-ticks?)))))
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
@author{@(author+email "Neil Toronto" (author-email))}
|
||||
|
||||
@defmodule[plot]
|
||||
@defmodule*/no-declare[(typed/plot)]
|
||||
|
||||
@(plot-name) provides a flexible interface for producing nearly any kind of plot.
|
||||
It includes many common kinds already, such as scatter plots, line plots, contour plots, histograms, and 3D surfaces and isosurfaces.
|
||||
|
|
4
collects/typed/plot.rkt
Normal file
4
collects/typed/plot.rkt
Normal file
|
@ -0,0 +1,4 @@
|
|||
#lang racket/base
|
||||
|
||||
(require "plot/main.rkt")
|
||||
(provide (all-from-out "plot/main.rkt"))
|
24
collects/typed/plot/common/nonrenderers.rkt
Normal file
24
collects/typed/plot/common/nonrenderers.rkt
Normal file
|
@ -0,0 +1,24 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "types.rkt")
|
||||
|
||||
(require/typed/provide
|
||||
plot
|
||||
[x-ticks ((Listof tick) [#:far? Boolean] -> nonrenderer)]
|
||||
[y-ticks ((Listof tick) [#:far? Boolean] -> nonrenderer)]
|
||||
[z-ticks ((Listof tick) [#:far? Boolean] -> nonrenderer)]
|
||||
|
||||
[invisible-rect ((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
-> nonrenderer)]
|
||||
|
||||
[invisible-rect3d ((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
-> nonrenderer)]
|
||||
)
|
159
collects/typed/plot/common/types.rkt
Normal file
159
collects/typed/plot/common/types.rkt
Normal file
|
@ -0,0 +1,159 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require (for-syntax racket/base)
|
||||
(only-in typed/mred/mred Color%))
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
(define-type (Treeof A) (Rec T (U A (Listof T))))
|
||||
|
||||
(define-type Plot-Device% (Class () () ()))
|
||||
(define-type 2D-Plot-Area% (Class () () ()))
|
||||
(define-type 3D-Plot-Area% (Class () () ()))
|
||||
|
||||
;; ===================================================================================================
|
||||
;; Struct types
|
||||
|
||||
(require/typed/provide
|
||||
plot/common/plot-device
|
||||
[plot-device% Plot-Device%])
|
||||
|
||||
(require/typed/provide
|
||||
plot/plot2d/plot-area
|
||||
[2d-plot-area% 2D-Plot-Area%])
|
||||
|
||||
(require/typed/provide
|
||||
plot/plot3d/plot-area
|
||||
[3d-plot-area% 3D-Plot-Area%])
|
||||
|
||||
(require-typed-struct/provide
|
||||
mapped-function
|
||||
([f : (Any -> Any)]
|
||||
[fmap : ((Listof Any) -> (Listof Any))])
|
||||
plot/utils)
|
||||
|
||||
(require-typed-struct/provide
|
||||
ivl
|
||||
([min : (Option Real)] [max : (Option Real)])
|
||||
plot/common/math)
|
||||
|
||||
(require-typed-struct/provide
|
||||
plot-time
|
||||
([second : Nonnegative-Integer]
|
||||
[minute : Nonnegative-Integer]
|
||||
[hour : Nonnegative-Integer]
|
||||
[day : Integer])
|
||||
plot/common/date-time)
|
||||
|
||||
(require-typed-struct/provide
|
||||
invertible-function
|
||||
([f : (Real -> Real)] [g : (Real -> Real)])
|
||||
plot/common/axis-transform)
|
||||
|
||||
(require-typed-struct/provide
|
||||
pre-tick
|
||||
([value : Real] [major? : Boolean])
|
||||
plot/common/ticks)
|
||||
|
||||
(require-typed-struct/provide
|
||||
(tick pre-tick)
|
||||
([label : String])
|
||||
plot/common/ticks)
|
||||
|
||||
(define-type Ticks-Layout (Real Real -> (Listof pre-tick)))
|
||||
(define-type Ticks-Format (Real Real (Listof pre-tick) -> (Listof String)))
|
||||
|
||||
(require-typed-struct/provide
|
||||
ticks
|
||||
([layout : Ticks-Layout]
|
||||
[format : Ticks-Format])
|
||||
plot/common/ticks)
|
||||
|
||||
(require-typed-struct/provide
|
||||
legend-entry
|
||||
([label : String]
|
||||
[draw : ((Instance Plot-Device%) Real Real -> Void)])
|
||||
plot/common/legend)
|
||||
|
||||
(define-type Bounds-Fun ((Vectorof ivl) -> (Vectorof ivl)))
|
||||
(define-type Ticks-Fun ((Vectorof ivl) -> Any))
|
||||
|
||||
(require-typed-struct/provide
|
||||
plot-element
|
||||
([bounds-rect : (Option (Vectorof ivl))]
|
||||
[bounds-fun : (Option Bounds-Fun)]
|
||||
[ticks-fun : (Option Ticks-Fun)])
|
||||
plot/common/plot-element)
|
||||
|
||||
(require-typed-struct/provide
|
||||
(nonrenderer plot-element)
|
||||
()
|
||||
plot/common/plot-element)
|
||||
|
||||
(require-typed-struct/provide
|
||||
(renderer2d plot-element)
|
||||
([render-proc : (Option ((Instance 2D-Plot-Area%) -> (Treeof legend-entry)))])
|
||||
plot/common/plot-element)
|
||||
|
||||
(require-typed-struct/provide
|
||||
(renderer3d plot-element)
|
||||
([render-proc : (Option ((Instance 3D-Plot-Area%) -> (Treeof legend-entry)))])
|
||||
plot/common/plot-element)
|
||||
|
||||
;; ===================================================================================================
|
||||
;; Styles and colors
|
||||
|
||||
(require (for-syntax (only-in plot/common/contract known-point-symbols)))
|
||||
|
||||
(define-syntax (define-point-sym-type stx)
|
||||
(syntax-case stx ()
|
||||
[(_ name)
|
||||
(with-syntax ([(point-sym-types ...) (map (λ (sym) `',sym) known-point-symbols)])
|
||||
(syntax/loc stx
|
||||
(define-type name (U point-sym-types ...))))]))
|
||||
|
||||
(define-point-sym-type Point-Sym)
|
||||
|
||||
(define-type Anchor
|
||||
(U 'top-left 'top 'top-right
|
||||
'left 'center 'right
|
||||
'bottom-left 'bottom 'bottom-right))
|
||||
|
||||
(define-type Font-Family
|
||||
(U 'default 'decorative 'roman 'script
|
||||
'swiss 'modern 'symbol 'system))
|
||||
|
||||
(define-type Color
|
||||
(U (List Real Real Real) String Symbol (Instance Color%)))
|
||||
|
||||
(define-type Plot-Color
|
||||
(U Integer Color))
|
||||
|
||||
(define-type Plot-Brush-Style
|
||||
(U Integer 'transparent 'solid
|
||||
'bdiagonal-hatch 'fdiagonal-hatch 'crossdiag-hatch
|
||||
'horizontal-hatch 'vertical-hatch 'cross-hatch))
|
||||
|
||||
(define-type Plot-Pen-Style
|
||||
(U Integer 'transparent 'solid 'dot 'long-dash 'short-dash 'dot-dash))
|
||||
|
||||
(define-type (Maybe-Function In Out) (U Out (In -> Out)))
|
||||
|
||||
(define-type (Plot-Colors In) (Maybe-Function In (Listof Plot-Color)))
|
||||
(define-type (Plot-Pen-Styles In) (Maybe-Function In (Listof Plot-Pen-Style)))
|
||||
(define-type (Pen-Widths In) (Maybe-Function In (Listof Real)))
|
||||
(define-type (Plot-Brush-Styles In) (Maybe-Function In (Listof Plot-Brush-Style)))
|
||||
(define-type (Alphas In) (Maybe-Function In (Listof Real)))
|
||||
(define-type (Labels In) (Maybe-Function In (Listof (Option String))))
|
||||
|
||||
;; ===================================================================================================
|
||||
;; Other argument and parameter types
|
||||
|
||||
(define-type Image-File-Format
|
||||
(U 'png 'jpeg
|
||||
'xmb 'xpm 'bmp
|
||||
'ps 'pdf 'svg))
|
||||
|
||||
(define-type Axis-Transform (Real Real invertible-function -> invertible-function))
|
||||
|
||||
(define-type Contour-Levels (U 'auto Positive-Integer (Listof Real)))
|
24
collects/typed/plot/contracted/axis-transform.rkt
Normal file
24
collects/typed/plot/contracted/axis-transform.rkt
Normal file
|
@ -0,0 +1,24 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt")
|
||||
|
||||
(require/typed/provide
|
||||
plot/contracted/axis-transform
|
||||
|
||||
[id-function invertible-function]
|
||||
[invertible-compose (invertible-function invertible-function -> invertible-function)]
|
||||
[invertible-inverse (invertible-function -> invertible-function)]
|
||||
|
||||
[id-transform Axis-Transform]
|
||||
[apply-axis-transform (Axis-Transform Real Real -> invertible-function)]
|
||||
[make-axis-transform (invertible-function -> Axis-Transform)]
|
||||
[axis-transform-compose (Axis-Transform Axis-Transform -> Axis-Transform)]
|
||||
[axis-transform-append (Axis-Transform Axis-Transform Real -> Axis-Transform)]
|
||||
[axis-transform-bound (Axis-Transform Real Real -> Axis-Transform)]
|
||||
|
||||
[log-transform Axis-Transform]
|
||||
[cbrt-transform Axis-Transform]
|
||||
[hand-drawn-transform (Real -> Axis-Transform)]
|
||||
[stretch-transform (Real Real Real -> Axis-Transform)]
|
||||
[collapse-transform (Real Real -> Axis-Transform)]
|
||||
)
|
14
collects/typed/plot/contracted/date-time.rkt
Normal file
14
collects/typed/plot/contracted/date-time.rkt
Normal file
|
@ -0,0 +1,14 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt")
|
||||
|
||||
(require/typed/provide
|
||||
plot/contracted/date-time
|
||||
#;
|
||||
[datetime->real ((U plot-time Date Date* SQL-Date SQL-Time SQL-Timestamp)
|
||||
-> Real)]
|
||||
|
||||
[datetime->real (plot-time -> Real)]
|
||||
[plot-time->seconds (plot-time -> Real)]
|
||||
[seconds->plot-time (Real -> plot-time)]
|
||||
)
|
20
collects/typed/plot/contracted/draw.rkt
Normal file
20
collects/typed/plot/contracted/draw.rkt
Normal file
|
@ -0,0 +1,20 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt")
|
||||
|
||||
(require/typed/provide
|
||||
plot/contracted/draw
|
||||
[->color (Color -> (List Real Real Real))]
|
||||
[->pen-color (Plot-Color -> (List Real Real Real))]
|
||||
[->brush-color (Plot-Color -> (List Real Real Real))]
|
||||
[->pen-style (Plot-Pen-Style -> Symbol)]
|
||||
[->brush-style (Plot-Brush-Style -> Symbol)]
|
||||
|
||||
[color-seq (Color Color Integer [#:start? Boolean] [#:end? Boolean]
|
||||
-> (Listof (List Real Real Real)))]
|
||||
|
||||
[color-seq* ((Listof Color) Integer [#:start? Boolean] [#:end? Boolean]
|
||||
-> (Listof (List Real Real Real)))]
|
||||
|
||||
[alpha-expt (Real Real -> Real)]
|
||||
)
|
32
collects/typed/plot/contracted/format.rkt
Normal file
32
collects/typed/plot/contracted/format.rkt
Normal file
|
@ -0,0 +1,32 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt")
|
||||
|
||||
(require/typed/provide
|
||||
plot/contracted/format
|
||||
|
||||
[integer->superscript (Integer -> String)]
|
||||
|
||||
[digits-for-range (case-> (Real Real -> Integer)
|
||||
(Real Real Integer -> Integer)
|
||||
(Real Real Integer Integer -> Integer))]
|
||||
|
||||
[real->decimal-string* (case-> (Real Integer -> String)
|
||||
(Real Integer Integer -> String))]
|
||||
|
||||
[real->string/trunc (Real Integer -> String)]
|
||||
|
||||
[real->plot-label (case-> (Real Integer -> Any)
|
||||
(Real Integer Boolean -> Any))]
|
||||
|
||||
[ivl->plot-label (case-> (ivl -> String)
|
||||
(ivl Integer -> String))]
|
||||
|
||||
[->plot-label (case-> (Any -> String)
|
||||
(Any Integer -> String))]
|
||||
|
||||
[parse-format-string (String -> (Listof (U String Symbol)))]
|
||||
|
||||
[apply-formatter (All (T) ((Symbol T -> (U String #f)) (Listof (U String Symbol)) T
|
||||
-> (Listof String)))]
|
||||
)
|
8
collects/typed/plot/contracted/kde.rkt
Normal file
8
collects/typed/plot/contracted/kde.rkt
Normal file
|
@ -0,0 +1,8 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt")
|
||||
|
||||
(require/typed/provide
|
||||
plot/contracted/kde
|
||||
[kde ((Listof Real) Real -> (Values mapped-function (Option Real) (Option Real)))]
|
||||
)
|
78
collects/typed/plot/contracted/math.rkt
Normal file
78
collects/typed/plot/contracted/math.rkt
Normal file
|
@ -0,0 +1,78 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt")
|
||||
|
||||
;; Misc
|
||||
(require/typed/provide
|
||||
plot/common/math
|
||||
[polar->cartesian (Real Real -> (Vector Real Real))]
|
||||
[3d-polar->3d-cartesian (Real Real Real -> (Vector Real Real Real))]
|
||||
[ceiling-log/base (Integer Real -> Integer)]
|
||||
[floor-log/base (Integer Real -> Integer)]
|
||||
[maybe-inexact->exact ((U #f Real) -> (U #f Real))]
|
||||
)
|
||||
|
||||
;; Vectors
|
||||
(require/typed/provide
|
||||
plot/common/math
|
||||
[v+ ((Vectorof Real) (Vectorof Real) -> (Vectorof Real))]
|
||||
[v- ((Vectorof Real) (Vectorof Real) -> (Vectorof Real))]
|
||||
[vneg ((Vectorof Real) -> (Vectorof Real))]
|
||||
[v* ((Vectorof Real) Real -> (Vectorof Real))]
|
||||
[v/ ((Vectorof Real) Real -> (Vectorof Real))]
|
||||
[v= ((Vectorof Real) (Vectorof Real) -> Boolean)]
|
||||
[vcross ((Vectorof Real) (Vectorof Real) -> (Vectorof Real))]
|
||||
[vcross2 ((Vectorof Real) (Vectorof Real) -> Real)]
|
||||
[vdot ((Vectorof Real) (Vectorof Real) -> Real)]
|
||||
[vmag^2 ((Vectorof Real) -> Real)]
|
||||
[vnormalize ((Vectorof Real) -> (Vectorof Real))]
|
||||
[vcenter ((Listof (Vectorof Real)) -> (Vectorof Real))]
|
||||
[vrational? ((Vectorof Real) -> Boolean)]
|
||||
[vcos-angle ((Vectorof Real) (Vectorof Real) -> Real)]
|
||||
)
|
||||
|
||||
;; Intervals
|
||||
(require/typed/provide
|
||||
plot/common/math
|
||||
[empty-ivl ivl]
|
||||
[unknown-ivl ivl]
|
||||
[rational-ivl? (Any -> Boolean)]
|
||||
[ivl-empty? (ivl -> Boolean)]
|
||||
[ivl-known? (ivl -> Boolean)]
|
||||
[ivl-rational? (ivl -> Boolean)]
|
||||
[ivl-singular? (ivl -> Boolean)]
|
||||
[ivl-length (ivl -> (U #f Real))]
|
||||
[ivl-center (ivl -> (U #f Real))]
|
||||
[ivl-zero-length? (ivl -> Boolean)]
|
||||
[ivl-inexact->exact (ivl -> ivl)]
|
||||
[ivl-contains? (ivl Real -> Boolean)]
|
||||
[ivl-meet (ivl * -> ivl)]
|
||||
[ivl-join (ivl * -> ivl)]
|
||||
[ivl-translate (ivl Real -> ivl)]
|
||||
[bounds->intervals ((Listof Real) -> (Listof ivl))]
|
||||
[clamp-real (Real ivl -> Real)]
|
||||
)
|
||||
|
||||
(define-type Rect (Vectorof ivl))
|
||||
(provide Rect)
|
||||
|
||||
;; Rectangles
|
||||
(require/typed/provide
|
||||
plot/common/math
|
||||
[empty-rect (Natural -> Rect)]
|
||||
[unknown-rect (Natural -> Rect)]
|
||||
[bounding-rect ((Listof Rect) -> Rect)]
|
||||
[rect-empty? (Rect -> Boolean)]
|
||||
[rect-known? (Rect -> Boolean)]
|
||||
[rect-rational? (Rect -> Boolean)]
|
||||
[rational-rect? (Any -> Boolean)]
|
||||
[rect-area (Rect -> (U #f Real))]
|
||||
[rect-center (Rect -> (Vectorof Real))]
|
||||
[rect-zero-area? (Rect -> Boolean)]
|
||||
[rect-singular? (Rect -> Boolean)]
|
||||
[rect-inexact->exact (Rect -> Rect)]
|
||||
[rect-contains? (Rect (Vectorof Real) -> Boolean)]
|
||||
[rect-meet (Rect * -> Rect)]
|
||||
[rect-join (Rect * -> Rect)]
|
||||
[rect-translate (Rect (Vectorof Real) -> Rect)]
|
||||
)
|
194
collects/typed/plot/contracted/parameters.rkt
Normal file
194
collects/typed/plot/contracted/parameters.rkt
Normal file
|
@ -0,0 +1,194 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt")
|
||||
|
||||
(require/typed/provide
|
||||
plot/contracted/parameters
|
||||
|
||||
;; 9.1 Compatibility
|
||||
[plot-deprecation-warnings? (Parameterof Boolean)]
|
||||
|
||||
;; 9.2 Output
|
||||
[plot-new-window? (Parameterof Boolean)]
|
||||
[plot-width (Parameterof Integer)]
|
||||
[plot-height (Parameterof Integer)]
|
||||
[plot-jpeg-quality (Parameterof Integer Natural)]
|
||||
[plot-ps/pdf-interactive? (Parameterof Boolean)]
|
||||
|
||||
;; 9.3 Appearance
|
||||
[plot-foreground (Parameterof Plot-Color)]
|
||||
[plot-background (Parameterof Plot-Color)]
|
||||
[plot-foreground-alpha (Parameterof Real)]
|
||||
[plot-font-size (Parameterof Real Nonnegative-Real)]
|
||||
[plot-font-family (Parameterof Font-Family)]
|
||||
[plot-line-width (Parameterof Real Nonnegative-Real)]
|
||||
[plot-legend-anchor (Parameterof Anchor)]
|
||||
[plot-legend-box-alpha (Parameterof Real Nonnegative-Real)]
|
||||
[plot-tick-size (Parameterof Real Nonnegative-Real)]
|
||||
[plot-title (Parameterof (Option String))]
|
||||
[plot-x-label (Parameterof (Option String))]
|
||||
[plot-y-label (Parameterof (Option String))]
|
||||
[plot-x-far-label (Parameterof (Option String))]
|
||||
[plot-y-far-label (Parameterof (Option String))]
|
||||
[plot-z-far-label (Parameterof (Option String))]
|
||||
[plot-x-tick-label-anchor (Parameterof Anchor)]
|
||||
[plot-x-tick-label-angle (Parameterof Real)]
|
||||
[plot-y-tick-label-anchor (Parameterof Anchor)]
|
||||
[plot-y-tick-label-angle (Parameterof Real)]
|
||||
[plot-x-far-tick-label-anchor (Parameterof Anchor)]
|
||||
[plot-x-far-tick-label-angle (Parameterof Real)]
|
||||
[plot-y-far-tick-label-anchor (Parameterof Anchor)]
|
||||
[plot-y-far-tick-label-angle (Parameterof Real)]
|
||||
[plot-x-axis? (Parameterof Boolean)]
|
||||
[plot-x-far-axis? (Parameterof Boolean)]
|
||||
[plot-y-axis? (Parameterof Boolean)]
|
||||
[plot-y-far-axis? (Parameterof Boolean)]
|
||||
[plot-z-axis? (Parameterof Boolean)]
|
||||
[plot-z-far-axis? (Parameterof Boolean)]
|
||||
[plot-animating? (Parameterof Boolean)]
|
||||
[animated-samples (Integer -> Integer)]
|
||||
[plot-decorations? (Parameterof Boolean)]
|
||||
|
||||
;; 9.4 Lines
|
||||
[line-samples (Parameterof Integer Natural)]
|
||||
[line-color (Parameterof Plot-Color)]
|
||||
[line-width (Parameterof Integer Natural)]
|
||||
[line-style (Parameterof Plot-Pen-Style)]
|
||||
[line-alpha (Parameterof Real Nonnegative-Real)]
|
||||
|
||||
;; 9.5 Intervals
|
||||
[interval-color (Parameterof Plot-Color)]
|
||||
[interval-style (Parameterof Plot-Brush-Style)]
|
||||
[interval-line1-color (Parameterof Plot-Color)]
|
||||
[interval-line1-width (Parameterof Real Nonnegative-Real)]
|
||||
[interval-line1-style (Parameterof Plot-Pen-Styles)]
|
||||
[interval-line2-color (Parameterof Plot-Color)]
|
||||
[interval-line2-width (Parameterof Real Nonnegative-Real)]
|
||||
[interval-line2-style (Parameterof Plot-Pen-Styles)]
|
||||
[interval-alpha (Parameterof Real)]
|
||||
|
||||
;; 9.6 Points
|
||||
[point-sym (Parameterof Point-Sym)]
|
||||
[point-color (Parameterof Plot-Color)]
|
||||
[point-size (Parameterof Real Nonnegative-Real)]
|
||||
[point-line-width (Parameterof Real Nonnegative-Real)]
|
||||
[point-alpha (Parameterof Real Nonnegative-Real)]
|
||||
|
||||
;; 9.7 Vector Fields
|
||||
[vector-field-samples (Parameterof Integer Positive-Integer)]
|
||||
[vector-field-color (Parameterof Plot-Color)]
|
||||
[vector-field-line-width (Parameterof Real Nonnegative-Real)]
|
||||
[vector-field-line-style (Parameterof Plot-Pen-Style)]
|
||||
[vector-field-scale (Parameterof (U Real 'auto 'normalized))]
|
||||
[vector-field-alpha (Parameterof Real Nonnegative-Real)]
|
||||
[vector-field3d-samples (Parameterof Integer Positive-Integer)]
|
||||
|
||||
;; 9.8 Error Bars
|
||||
[error-bar-width (Parameterof Real Nonnegative-Real)]
|
||||
[error-bar-color (Parameterof Plot-Color)]
|
||||
[error-bar-line-width (Parameterof Real Nonnegative-Real)]
|
||||
[error-bar-line-style (Parameterof Plot-Pen-Style)]
|
||||
[error-bar-alpha (Parameterof Real Nonnegative-Real)]
|
||||
|
||||
;; 9.9 Contours and Contour Intervals
|
||||
[default-contour-colors ((Listof Real) -> (Listof Plot-Color))]
|
||||
[default-contour-fill-colors ((Listof Real) -> (Listof Plot-Color))]
|
||||
[contour-samples (Parameterof Integer Natural)]
|
||||
[contour-levels (Parameterof (U 'auto Integer (Listof Real))
|
||||
(U 'auto Positive-Integer (Listof Real)))]
|
||||
[contour-colors (Parameterof (U Plot-Colors (Listof Real)))]
|
||||
[contour-widths (Parameterof (U Pen-Widths (Listof Real)))]
|
||||
[contour-styles (Parameterof (U Plot-Pen-Styles (Listof Real)))]
|
||||
[contour-alphas (Parameterof (U Alphas (Listof Real)))]
|
||||
[contour-interval-colors (U Plot-Colors (Listof ivl))]
|
||||
[contour-interval-styles (U Plot-Brush-Styles (Listof ivl))]
|
||||
[contour-interval-alphas (U Alphas (Listof ivl))]
|
||||
|
||||
;; 9.10 Rectangles
|
||||
[rectangle-color (Parameterof Plot-Color)]
|
||||
[rectangle-style (Parameterof Plot-Brush-Style)]
|
||||
[rectangle-line-color (Parameterof Plot-Color)]
|
||||
[rectangle-line-width (Parameterof Real Nonnegative-Real)]
|
||||
[rectangle-line-style (Parameterof Plot-Pen-Styles)]
|
||||
[rectangle-alpha (Parameterof Real Nonnegative-Real)]
|
||||
[rectangle3d-line-width (Parameterof Real Nonnegative-Real)]
|
||||
[discrete-histogram-skip (Parameterof Real Nonnegative-Real)]
|
||||
[discrete-histogram-invert? (Parameterof Boolean)]
|
||||
[stacked-histogram-alphas (Parameterof (U Alphas Integer) (U Alphas Natural))]
|
||||
[stacked-histogram-colors (Parameterof (U Plot-Colors Integer) (U Plot-Colors Natural))]
|
||||
[stacked-histogram-line-styles (Parameterof (U Plot-Pen-Styles Integer)
|
||||
(U Plot-Pen-Styles Natural))]
|
||||
[stacked-histogram-styles (Parameterof (U Plot-Brush-Styles Integer)
|
||||
(U Plot-Brush-Styles Natural))]
|
||||
|
||||
;; 9.11 Decorations
|
||||
[x-axis-alpha (Parameterof Real Nonnegative-Real)]
|
||||
[y-axis-alpha (Parameterof Real Nonnegative-Real)]
|
||||
[z-axis-alpha (Parameterof Real Nonnegative-Real)]
|
||||
[x-axis-far? (Parameterof Boolean)]
|
||||
[y-axis-far? (Parameterof Boolean)]
|
||||
[z-axis-far? (Parameterof Boolean)]
|
||||
[x-axis-ticks? (Parameterof Boolean)]
|
||||
[y-axis-ticks? (Parameterof Boolean)]
|
||||
[z-axis-ticks? (Parameterof Boolean)]
|
||||
[x-axis-labels? (Parameterof Boolean)]
|
||||
[y-axis-labels? (Parameterof Boolean)]
|
||||
[z-axis-labels? (Parameterof Boolean)]
|
||||
[polar-axes-number (Parameterof Integer Natural)]
|
||||
[polar-axes-alpha (Parameterof Real Nonnegative-Real)]
|
||||
[polar-axes-ticks? (Parameterof Boolean)]
|
||||
[polar-axes-labels? (Parameterof Boolean)]
|
||||
[label-anchor (Parameterof Anchor)]
|
||||
[label-angle (Parameterof Real)]
|
||||
[label-alpha (Parameterof Real Nonnegative-Real)]
|
||||
[label-point-size (Parameterof Real Nonnegative-Real)]
|
||||
|
||||
;; 9.12 General Appearance
|
||||
[plot3d-samples (Parameterof Integer)]
|
||||
[plot3d-angle (Parameterof Real)]
|
||||
[plot3d-altitude (Parameterof Real)]
|
||||
[plot3d-ambient-light (Parameterof Real Nonnegative-Real)]
|
||||
[plot3d-diffuse-light? (Parameterof Boolean)]
|
||||
[plot3d-specular-light? (Parameter Boolean)]
|
||||
|
||||
;; 9.13 Surfaces
|
||||
[surface-color (Parameterof Plot-Color)]
|
||||
[surface-style (Parameterof Plot-Brush-Style)]
|
||||
[surface-line-color (Parameterof Plot-Color)]
|
||||
[surface-line-width (Parameterof Real Nonnegative-Real)]
|
||||
[surface-alpha (Parameterof Real Nonnegative-Real)]
|
||||
|
||||
;; 9.14 Contour Surfaces
|
||||
[contour-interval-line-colors (Parameterof (U Plot-Colors (Listof ivl)))]
|
||||
[contour-interval-line-widths (Parameterof (U Pen-Widths (Listof ivl)))]
|
||||
[contour-interval-line-styles (Parameterof (U Plot-Pen-Styles (Listof ivl)))]
|
||||
|
||||
;; 9.15 Isosurfaces
|
||||
[default-isosurface-colors ((Listof Real) -> (Listof Plot-Color))]
|
||||
[default-isosurface-line-colors ((Listof Real) -> (Listof Plot-Color))]
|
||||
[isosurface-levels (Parameterof (U 'auto Integer (Listof Real)) (U 'auto Natural (Listof Real)))]
|
||||
[isosurface-colors (Parameterof (U Plot-Colors (Listof Real)))]
|
||||
[isosurface-styles (Parameterof (U Plot-Brush-Styles (Listof Real)))]
|
||||
[isosurface-line-colors (Parameterof (U Plot-Colors (Listof Real)))]
|
||||
[isosurface-line-widths (U Pen-Widths (Listof Real))]
|
||||
[isosurface-line-styles (U Plot-Pen-Styles (Listof Real))]
|
||||
[isosurface-alphas (U Alphas (Listof Real))]
|
||||
|
||||
;; 7.1 Axis Transforms
|
||||
[plot-x-transform (Parameterof Axis-Transform)]
|
||||
[plot-y-transform (Parameterof Axis-Transform)]
|
||||
[plot-z-transform (Parameterof Axis-Transform)]
|
||||
|
||||
;; 7.2 Axis Ticks
|
||||
[plot-x-ticks (Parameterof ticks)]
|
||||
[plot-x-far-ticks (Parameterof ticks)]
|
||||
|
||||
[plot-y-ticks (Parameterof ticks)]
|
||||
[plot-y-far-ticks (Parameterof ticks)]
|
||||
|
||||
[plot-z-ticks (Parameterof ticks)]
|
||||
[plot-z-far-ticks (Parameterof ticks)]
|
||||
|
||||
[plot-d-ticks (Parameterof ticks)]
|
||||
[plot-r-ticks (Parameterof ticks)]
|
||||
)
|
15
collects/typed/plot/contracted/sample.rkt
Normal file
15
collects/typed/plot/contracted/sample.rkt
Normal file
|
@ -0,0 +1,15 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
;; This is very incomplete, but exports enough that typed/plot/utils at least exports typed versions
|
||||
;; all of the *documented* functions in plot/utils
|
||||
|
||||
(require "../common/types.rkt")
|
||||
|
||||
(require/typed/provide
|
||||
plot/contracted/sample
|
||||
[linear-seq (Real Real Integer [#:start? Boolean] [#:end? Boolean] -> (Listof Real))]
|
||||
|
||||
[linear-seq* ((Listof Real) Integer [#:start? Boolean] [#:end? Boolean] -> (Listof Real))]
|
||||
|
||||
[nonlinear-seq (Real Real Integer Axis-Transform
|
||||
[#:start? Boolean] [#:end? Boolean] -> (Listof Real))])
|
72
collects/typed/plot/contracted/ticks.rkt
Normal file
72
collects/typed/plot/contracted/ticks.rkt
Normal file
|
@ -0,0 +1,72 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt")
|
||||
|
||||
(require/typed/provide
|
||||
plot/contracted/ticks
|
||||
[24h-descending-date-ticks-formats (Listof String)]
|
||||
[12h-descending-date-ticks-formats (Listof String)]
|
||||
[24h-descending-time-ticks-formats (Listof String)]
|
||||
[12h-descending-time-ticks-formats (Listof String)]
|
||||
[us-currency-scales (Listof String)]
|
||||
[uk-currency-scales (Listof String)]
|
||||
[eu-currency-scales (Listof String)]
|
||||
[us-currency-formats (Listof String)]
|
||||
[uk-currency-formats (Listof String)]
|
||||
[eu-currency-formats (Listof String)]
|
||||
|
||||
[ticks-default-number (Parameterof Integer Positive-Integer)]
|
||||
[date-ticks-formats (Parameterof (Listof String))]
|
||||
[time-ticks-formats (Parameterof (Listof String))]
|
||||
[currency-ticks-scales (Parameterof (Listof String))]
|
||||
[currency-ticks-formats (Parameterof (List String String String))]
|
||||
|
||||
[no-ticks-layout Ticks-Layout]
|
||||
[no-ticks-format Ticks-Format]
|
||||
[no-ticks ticks]
|
||||
|
||||
[ticks-mimic ((-> ticks) -> ticks)]
|
||||
[ticks-scale (ticks invertible-function -> ticks)]
|
||||
[ticks-add (case-> (ticks (Listof Real) -> ticks)
|
||||
(ticks (Listof Real) Boolean -> ticks))]
|
||||
|
||||
[linear-scale (case-> (Real -> invertible-function)
|
||||
(Real Real -> invertible-function))]
|
||||
|
||||
[linear-ticks-layout
|
||||
([#:number Integer] [#:base Integer] [#:divisors (Listof Integer)] -> Ticks-Layout)]
|
||||
[linear-ticks-format (-> Ticks-Format)]
|
||||
[linear-ticks ([#:number Integer] [#:base Integer] [#:divisors (Listof Integer)] -> ticks)]
|
||||
|
||||
[log-ticks-layout ([#:number Integer] [#:base Integer] -> Ticks-Layout)]
|
||||
[log-ticks-format ([#:base Integer] -> Ticks-Format)]
|
||||
[log-ticks ([#:number Integer] [#:base Integer] -> ticks)]
|
||||
|
||||
[date-ticks-layout ([#:number Integer] -> Ticks-Layout)]
|
||||
[date-ticks-format ([#:formats (Listof String)] -> Ticks-Format)]
|
||||
[date-ticks ([#:number Integer] [#:formats (Listof String)] -> ticks)]
|
||||
|
||||
[time-ticks-layout ([#:number Integer] -> Ticks-Layout)]
|
||||
[time-ticks-format ([#:formats (Listof String)] -> Ticks-Format)]
|
||||
[time-ticks ([#:number Integer] [#:formats (Listof String)] -> ticks)]
|
||||
|
||||
[bit/byte-ticks-format ([#:size (U 'byte 'bit)] [#:kind (U 'CS 'SI)] -> Ticks-Format)]
|
||||
[bit/byte-ticks ([#:number Integer] [#:size (U 'byte 'bit)] [#:kind (U 'CS 'SI)] -> ticks)]
|
||||
|
||||
[fraction-ticks-format ([#:base Integer] [#:divisors (Listof Integer)] -> Ticks-Format)]
|
||||
[fraction-ticks ([#:base Integer] [#:divisors (Listof Integer)] -> ticks)]
|
||||
|
||||
[currency-ticks-format ([#:kind (U String Symbol)]
|
||||
[#:scales (Listof String)]
|
||||
[#:formats (List String String String)]
|
||||
-> Ticks-Format)]
|
||||
[currency-ticks ([#:number Integer]
|
||||
[#:kind (U String Symbol)]
|
||||
[#:scales (Listof String)]
|
||||
[#:formats (List String String String)]
|
||||
-> Ticks-Format)]
|
||||
|
||||
[contour-ticks (ticks Real Real Contour-Levels Boolean -> (Listof tick))]
|
||||
|
||||
[format-tick-labels (ticks Real Real (Listof Real) -> (Listof String))]
|
||||
)
|
76
collects/typed/plot/main.rkt
Normal file
76
collects/typed/plot/main.rkt
Normal file
|
@ -0,0 +1,76 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
;; Every require/provide pair in this file corresponds with a require/provide pair in plot/main
|
||||
|
||||
;; ===================================================================================================
|
||||
;; General exports
|
||||
|
||||
(require "common/types.rkt")
|
||||
(provide (all-from-out "common/types.rkt"))
|
||||
|
||||
(require "contracted/parameters.rkt")
|
||||
(provide (all-from-out "contracted/parameters.rkt"))
|
||||
|
||||
;; Not necessary because re-exporting "types.rkt" exports the `ivl' struct
|
||||
;(require "contracted/math.rkt")
|
||||
;(provide (struct-out ivl))
|
||||
|
||||
(require "contracted/axis-transform.rkt")
|
||||
(provide (all-from-out "contracted/axis-transform.rkt"))
|
||||
|
||||
(require "contracted/ticks.rkt")
|
||||
(provide (all-from-out "contracted/ticks.rkt"))
|
||||
|
||||
(require "contracted/date-time.rkt")
|
||||
(provide plot-time->seconds seconds->plot-time datetime->real)
|
||||
|
||||
(require "common/nonrenderers.rkt")
|
||||
(provide (all-from-out "common/nonrenderers.rkt"))
|
||||
|
||||
;; ===================================================================================================
|
||||
;; 2D exports
|
||||
|
||||
(require "plot2d/plot.rkt")
|
||||
(provide (all-from-out "plot2d/plot.rkt"))
|
||||
|
||||
(require "plot2d/point.rkt")
|
||||
(provide (all-from-out "plot2d/point.rkt"))
|
||||
|
||||
(require "plot2d/line.rkt")
|
||||
(provide (all-from-out "plot2d/line.rkt"))
|
||||
|
||||
(require "plot2d/interval.rkt")
|
||||
(provide (all-from-out "plot2d/interval.rkt"))
|
||||
|
||||
(require "plot2d/contour.rkt")
|
||||
(provide (all-from-out "plot2d/contour.rkt"))
|
||||
|
||||
(require "plot2d/rectangle.rkt")
|
||||
(provide (all-from-out "plot2d/rectangle.rkt"))
|
||||
|
||||
(require "plot2d/decoration.rkt")
|
||||
(provide (all-from-out "plot2d/decoration.rkt"))
|
||||
|
||||
;; ===================================================================================================
|
||||
;; 3D exports
|
||||
|
||||
(require "plot3d/plot.rkt")
|
||||
(provide (all-from-out "plot3d/plot.rkt"))
|
||||
|
||||
(require "plot3d/surface.rkt")
|
||||
(provide (all-from-out "plot3d/surface.rkt"))
|
||||
|
||||
(require "plot3d/contour.rkt")
|
||||
(provide (all-from-out "plot3d/contour.rkt"))
|
||||
|
||||
(require "plot3d/line.rkt")
|
||||
(provide (all-from-out "plot3d/line.rkt"))
|
||||
|
||||
(require "plot3d/point.rkt")
|
||||
(provide (all-from-out "plot3d/point.rkt"))
|
||||
|
||||
(require "plot3d/isosurface.rkt")
|
||||
(provide (all-from-out "plot3d/isosurface.rkt"))
|
||||
|
||||
(require "plot3d/rectangle.rkt")
|
||||
(provide (all-from-out "plot3d/rectangle.rkt"))
|
53
collects/typed/plot/plot2d/contour.rkt
Normal file
53
collects/typed/plot/plot2d/contour.rkt
Normal file
|
@ -0,0 +1,53 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide isoline contours contour-intervals)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[isoline (((Real Real -> Real) Real)
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
|
||||
[contours (((Real Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:samples Integer]
|
||||
[#:levels Contour-Levels]
|
||||
[#:colors (Plot-Colors (Listof Real))]
|
||||
[#:widths (Pen-Widths (Listof Real))]
|
||||
[#:styles (Plot-Pen-Styles (Listof Real))]
|
||||
[#:alphas (Alphas (Listof Real))]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
|
||||
[contour-intervals (((Real Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:samples Integer]
|
||||
[#:levels Contour-Levels]
|
||||
[#:colors (Plot-Colors (Listof ivl))]
|
||||
[#:styles (Plot-Brush-Styles (Listof ivl))]
|
||||
[#:contour-colors (Plot-Colors (Listof Real))]
|
||||
[#:contour-widths (Pen-Widths (Listof Real))]
|
||||
[#:contour-styles (Plot-Pen-Styles (Listof Real))]
|
||||
[#:alphas (Alphas (Listof ivl))]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
)
|
124
collects/typed/plot/plot2d/decoration.rkt
Normal file
124
collects/typed/plot/plot2d/decoration.rkt
Normal file
|
@ -0,0 +1,124 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide x-axis y-axis axes polar-axes
|
||||
x-tick-lines y-tick-lines tick-grid
|
||||
point-label parametric-label polar-label function-label inverse-label)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[x-axis (()
|
||||
(Real
|
||||
[#:ticks? Boolean]
|
||||
[#:labels? Boolean]
|
||||
[#:far? Boolean]
|
||||
[#:alpha Real])
|
||||
->* renderer2d)]
|
||||
|
||||
[y-axis (()
|
||||
(Real
|
||||
[#:ticks? Boolean]
|
||||
[#:labels? Boolean]
|
||||
[#:far? Boolean]
|
||||
[#:alpha Real])
|
||||
->* renderer2d)]
|
||||
|
||||
[axes (()
|
||||
(Real
|
||||
Real
|
||||
[#:x-ticks? Boolean]
|
||||
[#:y-ticks? Boolean]
|
||||
[#:x-labels? Boolean]
|
||||
[#:y-labels? Boolean]
|
||||
[#:x-alpha Real]
|
||||
[#:y-alpha Real])
|
||||
->* (Listof renderer2d))]
|
||||
|
||||
[polar-axes ([#:number Integer]
|
||||
[#:ticks? Boolean]
|
||||
[#:labels? Boolean]
|
||||
[#:alpha Real]
|
||||
-> renderer2d)]
|
||||
|
||||
[x-tick-lines (-> renderer2d)]
|
||||
[y-tick-lines (-> renderer2d)]
|
||||
[tick-grid (-> (Listof renderer2d))]
|
||||
|
||||
[point-label (((Sequenceof Real))
|
||||
((Option String)
|
||||
[#:color Plot-Color]
|
||||
[#:size Real]
|
||||
[#:family Font-Family]
|
||||
[#:anchor Anchor]
|
||||
[#:angle Real]
|
||||
[#:point-color Plot-Color]
|
||||
[#:point-fill-color (U Plot-Color 'auto)]
|
||||
[#:point-size Real]
|
||||
[#:point-line-width Real]
|
||||
[#:point-sym Point-Sym]
|
||||
[#:alpha Real])
|
||||
->* renderer2d)]
|
||||
|
||||
[parametric-label (((Real -> (Sequenceof Real)) Real)
|
||||
((Option String)
|
||||
[#:color Plot-Color]
|
||||
[#:size Real]
|
||||
[#:family Font-Family]
|
||||
[#:anchor Anchor]
|
||||
[#:angle Real]
|
||||
[#:point-color Plot-Color]
|
||||
[#:point-fill-color (U Plot-Color 'auto)]
|
||||
[#:point-size Real]
|
||||
[#:point-line-width Real]
|
||||
[#:point-sym Point-Sym]
|
||||
[#:alpha Real])
|
||||
->* renderer2d)]
|
||||
|
||||
[polar-label (((Real -> Real) Real)
|
||||
((Option String)
|
||||
[#:color Plot-Color]
|
||||
[#:size Real]
|
||||
[#:family Font-Family]
|
||||
[#:anchor Anchor]
|
||||
[#:angle Real]
|
||||
[#:point-color Plot-Color]
|
||||
[#:point-fill-color (U Plot-Color 'auto)]
|
||||
[#:point-size Real]
|
||||
[#:point-line-width Real]
|
||||
[#:point-sym Point-Sym]
|
||||
[#:alpha Real])
|
||||
->* renderer2d)]
|
||||
|
||||
[function-label (((Real -> Real) Real)
|
||||
((Option String)
|
||||
[#:color Plot-Color]
|
||||
[#:size Real]
|
||||
[#:family Font-Family]
|
||||
[#:anchor Anchor]
|
||||
[#:angle Real]
|
||||
[#:point-color Plot-Color]
|
||||
[#:point-fill-color (U Plot-Color 'auto)]
|
||||
[#:point-size Real]
|
||||
[#:point-line-width Real]
|
||||
[#:point-sym Point-Sym]
|
||||
[#:alpha Real])
|
||||
->* renderer2d)]
|
||||
|
||||
[inverse-label (((Real -> Real) Real)
|
||||
((Option String)
|
||||
[#:color Plot-Color]
|
||||
[#:size Real]
|
||||
[#:family Font-Family]
|
||||
[#:anchor Anchor]
|
||||
[#:angle Real]
|
||||
[#:point-color Plot-Color]
|
||||
[#:point-fill-color (U Plot-Color 'auto)]
|
||||
[#:point-size Real]
|
||||
[#:point-line-width Real]
|
||||
[#:point-sym Point-Sym]
|
||||
[#:alpha Real])
|
||||
->* renderer2d)]
|
||||
)
|
108
collects/typed/plot/plot2d/interval.rkt
Normal file
108
collects/typed/plot/plot2d/interval.rkt
Normal file
|
@ -0,0 +1,108 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide lines-interval parametric-interval polar-interval function-interval inverse-interval)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[lines-interval ((Sequenceof (Sequenceof Real))
|
||||
(Sequenceof (Sequenceof Real))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line1-color Plot-Color]
|
||||
[#:line1-width Real]
|
||||
[#:line1-style Plot-Pen-Style]
|
||||
[#:line2-color Plot-Color]
|
||||
[#:line2-width Real]
|
||||
[#:line2-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer2d)]
|
||||
|
||||
[parametric-interval ((Real -> (Sequenceof Real))
|
||||
(Real -> (Sequenceof Real))
|
||||
Real
|
||||
Real
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line1-color Plot-Color]
|
||||
[#:line1-width Real]
|
||||
[#:line1-style Plot-Pen-Style]
|
||||
[#:line2-color Plot-Color]
|
||||
[#:line2-width Real]
|
||||
[#:line2-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer2d)]
|
||||
|
||||
[polar-interval (((Real -> Real)
|
||||
(Real -> Real))
|
||||
(Real
|
||||
Real
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line1-color Plot-Color]
|
||||
[#:line1-width Real]
|
||||
[#:line1-style Plot-Pen-Style]
|
||||
[#:line2-color Plot-Color]
|
||||
[#:line2-width Real]
|
||||
[#:line2-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
|
||||
[function-interval (((Real -> Real)
|
||||
(Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line1-color Plot-Color]
|
||||
[#:line1-width Real]
|
||||
[#:line1-style Plot-Pen-Style]
|
||||
[#:line2-color Plot-Color]
|
||||
[#:line2-width Real]
|
||||
[#:line2-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
|
||||
[inverse-interval (((Real -> Real)
|
||||
(Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line1-color Plot-Color]
|
||||
[#:line1-width Real]
|
||||
[#:line1-style Plot-Pen-Style]
|
||||
[#:line2-color Plot-Color]
|
||||
[#:line2-width Real]
|
||||
[#:line2-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
)
|
92
collects/typed/plot/plot2d/line.rkt
Normal file
92
collects/typed/plot/plot2d/line.rkt
Normal file
|
@ -0,0 +1,92 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide lines parametric polar function inverse density)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[lines ((Sequenceof (Sequenceof Real))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer2d)]
|
||||
|
||||
[parametric ((Real -> (Sequenceof Real))
|
||||
Real
|
||||
Real
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer2d)]
|
||||
|
||||
[polar (((Real -> Real))
|
||||
(Real
|
||||
Real
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min Real]
|
||||
[#:y-max Real]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
|
||||
[function (((Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
|
||||
[inverse (((Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
|
||||
[density (((Sequenceof Real))
|
||||
(Real
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
)
|
112
collects/typed/plot/plot2d/plot.rkt
Normal file
112
collects/typed/plot/plot2d/plot.rkt
Normal file
|
@ -0,0 +1,112 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require (only-in typed/mred/mred Snip% Bitmap% Frame%)
|
||||
"../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide plot
|
||||
plot-file
|
||||
;plot-pict ; can't be typed yet
|
||||
plot-bitmap
|
||||
plot-snip
|
||||
plot-frame
|
||||
plot/dc)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[plot ((Treeof (U renderer2d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
[#:out-file (Option (U Path-String Output-Port))]
|
||||
[#:out-kind (U 'auto Image-File-Format)]
|
||||
-> (U (Instance Snip%) Void))]
|
||||
|
||||
[plot-file (((Treeof (U renderer2d nonrenderer))
|
||||
(U Path-String Output-Port))
|
||||
((U 'auto Image-File-Format)
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:legend-anchor Anchor])
|
||||
->* Void)]
|
||||
|
||||
#;; Picts are from slideshow/pict, which isn't typed yet
|
||||
[plot-pict ((Treeof (U renderer2d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> Pict)]
|
||||
|
||||
[plot-bitmap ((Treeof (U renderer2d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> (Instance Bitmap%))]
|
||||
|
||||
[plot-snip ((Treeof (U renderer2d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> (Instance Snip%))]
|
||||
|
||||
[plot-frame ((Treeof (U renderer2d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> (Instance Frame%))]
|
||||
|
||||
[plot/dc ((Treeof (U renderer2d nonrenderer))
|
||||
Any Real Real Real Real
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> Void)]
|
||||
)
|
50
collects/typed/plot/plot2d/point.rkt
Normal file
50
collects/typed/plot/plot2d/point.rkt
Normal file
|
@ -0,0 +1,50 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide points vector-field error-bars)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[points ((Sequenceof (Sequenceof Real))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:sym Point-Sym]
|
||||
[#:color Plot-Color]
|
||||
[#:fill-color (U Plot-Color 'auto)]
|
||||
[#:size Real]
|
||||
[#:line-width Real]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer2d)]
|
||||
|
||||
[vector-field (((Real Real -> (Sequenceof Real)))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:samples Integer]
|
||||
[#:scale (U Real 'auto 'normalized)]
|
||||
[#:color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer2d)]
|
||||
|
||||
[error-bars ((Sequenceof (Sequenceof Real))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:color Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:width Real]
|
||||
[#:alpha Real]
|
||||
-> renderer2d)]
|
||||
)
|
80
collects/typed/plot/plot2d/rectangle.rkt
Normal file
80
collects/typed/plot/plot2d/rectangle.rkt
Normal file
|
@ -0,0 +1,80 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide rectangles area-histogram discrete-histogram stacked-histogram)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[rectangles ((Sequenceof (Sequenceof ivl))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line-color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer2d)]
|
||||
|
||||
[area-histogram ((Real -> Real)
|
||||
(Sequenceof Real)
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line-color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer2d)]
|
||||
|
||||
[discrete-histogram ((Sequenceof (U (Vector Any (U Real ivl #f))
|
||||
(List Any (U Real ivl #f))))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:gap Real]
|
||||
[#:skip Real]
|
||||
[#:invert? Boolean]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line-color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
[#:add-ticks? Boolean]
|
||||
[#:far-ticks? Boolean]
|
||||
-> renderer2d)]
|
||||
|
||||
[stacked-histogram ((Sequenceof (U (Vector Any (Sequenceof Real))
|
||||
(List Any (Sequenceof Real))))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:gap Real]
|
||||
[#:skip Real]
|
||||
[#:invert? Boolean]
|
||||
[#:colors (Plot-Colors Natural)]
|
||||
[#:styles (Plot-Brush-Styles Natural)]
|
||||
[#:line-colors (Plot-Colors Natural)]
|
||||
[#:line-widths (Pen-Widths Natural)]
|
||||
[#:line-styles (Plot-Pen-Styles Natural)]
|
||||
[#:alphas (Alphas Natural)]
|
||||
[#:labels (Labels Natural)]
|
||||
[#:add-ticks? Boolean]
|
||||
[#:far-ticks? Boolean]
|
||||
-> (Listof renderer2d))]
|
||||
)
|
62
collects/typed/plot/plot3d/contour.rkt
Normal file
62
collects/typed/plot/plot3d/contour.rkt
Normal file
|
@ -0,0 +1,62 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide isoline3d contours3d contour-intervals3d)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[isoline3d (((Real Real -> Real) Real)
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer3d)]
|
||||
|
||||
[contours3d (((Real Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:levels Contour-Levels]
|
||||
[#:colors (Plot-Colors (Listof Real))]
|
||||
[#:widths (Pen-Widths (Listof Real))]
|
||||
[#:styles (Plot-Pen-Styles (Listof Real))]
|
||||
[#:alphas (Alphas (Listof Real))]
|
||||
[#:label (Option String)])
|
||||
->* renderer3d)]
|
||||
|
||||
[contour-intervals3d (((Real Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:levels Contour-Levels]
|
||||
[#:colors (Plot-Colors (Listof ivl))]
|
||||
[#:styles (Plot-Brush-Styles (Listof ivl))]
|
||||
[#:line-colors (Plot-Colors (Listof ivl))]
|
||||
[#:line-widths (Pen-Widths (Listof ivl))]
|
||||
[#:line-styles (Plot-Pen-Styles (Listof ivl))]
|
||||
[#:contour-colors (Plot-Colors (Listof Real))]
|
||||
[#:contour-widths (Plot-Colors (Listof Real))]
|
||||
[#:contour-styles (Plot-Pen-Styles (Listof Real))]
|
||||
[#:alphas (Alphas (Listof ivl))]
|
||||
[#:label (Option String)])
|
||||
->* renderer3d)]
|
||||
)
|
64
collects/typed/plot/plot3d/isosurface.rkt
Normal file
64
collects/typed/plot/plot3d/isosurface.rkt
Normal file
|
@ -0,0 +1,64 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide isosurface3d isosurfaces3d polar3d)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[isosurface3d (((Real Real Real -> Real) Real)
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line-color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer3d)]
|
||||
|
||||
[isosurfaces3d (((Real Real Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:d-min (Option Real)]
|
||||
[#:d-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:levels Contour-Levels]
|
||||
[#:colors (Plot-Colors (Listof Real))]
|
||||
[#:styles (Plot-Brush-Styles (Listof Real))]
|
||||
[#:line-colors (Plot-Colors (Listof Real))]
|
||||
[#:line-widths (Pen-Widths (Listof Real))]
|
||||
[#:line-styles (Plot-Pen-Styles (Listof Real))]
|
||||
[#:alphas (Alphas (Listof Real))]
|
||||
[#:label (Option String)])
|
||||
->* renderer3d)]
|
||||
|
||||
[polar3d ((Real Real -> Real)
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line-color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer3d)]
|
||||
)
|
41
collects/typed/plot/plot3d/line.rkt
Normal file
41
collects/typed/plot/plot3d/line.rkt
Normal file
|
@ -0,0 +1,41 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide lines3d parametric3d)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[lines3d ((Sequenceof (Sequenceof Real))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer3d)]
|
||||
|
||||
[parametric3d ((Real -> (Sequenceof Real))
|
||||
Real
|
||||
Real
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:width Real]
|
||||
[#:style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer3d)]
|
||||
)
|
147
collects/typed/plot/plot3d/plot.rkt
Normal file
147
collects/typed/plot/plot3d/plot.rkt
Normal file
|
@ -0,0 +1,147 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require (only-in typed/mred/mred Snip% Bitmap% Frame%)
|
||||
"../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide plot3d
|
||||
plot3d-file
|
||||
;plot3d-pict ; can't be typed yet
|
||||
plot3d-bitmap
|
||||
plot3d-snip
|
||||
plot3d-frame
|
||||
plot3d/dc)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[plot3d ((Treeof (U renderer3d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:angle Real]
|
||||
[#:altitude Real]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:z-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
[#:out-file (Option (U Path-String Output-Port))]
|
||||
[#:out-kind (U 'auto Image-File-Format)]
|
||||
-> (U (Instance Snip%) Void))]
|
||||
|
||||
[plot3d-file (((Treeof (U renderer3d nonrenderer))
|
||||
(U Path-String Output-Port))
|
||||
((U 'auto Image-File-Format)
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:angle Real]
|
||||
[#:altitude Real]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:z-label (Option String)]
|
||||
[#:legend-anchor Anchor])
|
||||
->* Void)]
|
||||
|
||||
#;; Picts are from slideshow/pict, which isn't typed yet
|
||||
[plot3d-pict ((Treeof (U renderer3d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:angle Real]
|
||||
[#:altitude Real]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:z-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> Pict)]
|
||||
|
||||
[plot3d-bitmap ((Treeof (U renderer3d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:angle Real]
|
||||
[#:altitude Real]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:z-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> (Instance Bitmap%))]
|
||||
|
||||
[plot3d-snip ((Treeof (U renderer3d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:angle Real]
|
||||
[#:altitude Real]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:z-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> (Instance Snip%))]
|
||||
|
||||
[plot3d-frame ((Treeof (U renderer3d nonrenderer))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:width Integer]
|
||||
[#:height Integer]
|
||||
[#:angle Real]
|
||||
[#:altitude Real]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:z-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> (Instance Frame%))]
|
||||
|
||||
[plot3d/dc ((Treeof (U renderer3d nonrenderer))
|
||||
Any Real Real Real Real
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:angle Real]
|
||||
[#:altitude Real]
|
||||
[#:title (Option String)]
|
||||
[#:x-label (Option String)]
|
||||
[#:y-label (Option String)]
|
||||
[#:z-label (Option String)]
|
||||
[#:legend-anchor Anchor]
|
||||
-> Void)]
|
||||
)
|
43
collects/typed/plot/plot3d/point.rkt
Normal file
43
collects/typed/plot/plot3d/point.rkt
Normal file
|
@ -0,0 +1,43 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide points3d vector-field3d)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[points3d ((Sequenceof (Sequenceof Real))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:sym Point-Sym]
|
||||
[#:color Plot-Color]
|
||||
[#:fill-color (U Plot-Color 'auto)]
|
||||
[#:size Real]
|
||||
[#:line-width Real]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer3d)]
|
||||
|
||||
[vector-field3d (((U (Real Real Real -> (Sequenceof Real))
|
||||
((Vector Real Real Real) -> (Sequenceof Real))))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:samples Integer]
|
||||
[#:scale (U Real 'auto 'normalized)]
|
||||
[#:color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer3d)]
|
||||
)
|
70
collects/typed/plot/plot3d/rectangle.rkt
Normal file
70
collects/typed/plot/plot3d/rectangle.rkt
Normal file
|
@ -0,0 +1,70 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide rectangles3d discrete-histogram3d stacked-histogram3d)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[rectangles3d ((Sequenceof (Sequenceof ivl))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line-color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
-> renderer3d)]
|
||||
|
||||
[discrete-histogram3d ((Sequenceof (U (Vector Any Any (Option (U Real ivl)))
|
||||
(List Any Any (Option (U Real ivl)))))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:gap Real]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line-color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)]
|
||||
[#:add-x-ticks? Boolean]
|
||||
[#:add-y-ticks? Boolean]
|
||||
[#:x-far-ticks? Boolean]
|
||||
[#:y-far-ticks? Boolean]
|
||||
-> renderer3d)]
|
||||
|
||||
[stacked-histogram3d ((Sequenceof (U (Vector Any Any (Sequenceof Real))
|
||||
(List Any Any (Sequenceof Real))))
|
||||
[#:x-min (Option Real)]
|
||||
[#:x-max (Option Real)]
|
||||
[#:y-min (Option Real)]
|
||||
[#:y-max (Option Real)]
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:gap Real]
|
||||
[#:colors (Plot-Colors Natural)]
|
||||
[#:styles (Plot-Brush-Styles Natural)]
|
||||
[#:line-colors (Plot-Colors Natural)]
|
||||
[#:line-widths (Pen-Widths Natural)]
|
||||
[#:line-styles (Plot-Pen-Styles Natural)]
|
||||
[#:alphas (Alphas Natural)]
|
||||
[#:labels (Labels Natural)]
|
||||
[#:add-x-ticks? Boolean]
|
||||
[#:add-y-ticks? Boolean]
|
||||
[#:x-far-ticks? Boolean]
|
||||
[#:y-far-ticks? Boolean]
|
||||
-> (Listof renderer3d))]
|
||||
)
|
27
collects/typed/plot/plot3d/surface.rkt
Normal file
27
collects/typed/plot/plot3d/surface.rkt
Normal file
|
@ -0,0 +1,27 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(require "../common/types.rkt"
|
||||
"../syntax.rkt")
|
||||
|
||||
(provide surface3d)
|
||||
|
||||
(require/typed*
|
||||
plot
|
||||
|
||||
[surface3d (((Real Real -> Real))
|
||||
((Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
(Option Real)
|
||||
[#:z-min (Option Real)]
|
||||
[#:z-max (Option Real)]
|
||||
[#:samples Integer]
|
||||
[#:color Plot-Color]
|
||||
[#:style Plot-Brush-Style]
|
||||
[#:line-color Plot-Color]
|
||||
[#:line-width Real]
|
||||
[#:line-style Plot-Pen-Style]
|
||||
[#:alpha Real]
|
||||
[#:label (Option String)])
|
||||
->* renderer3d)]
|
||||
)
|
43
collects/typed/plot/syntax.rkt
Normal file
43
collects/typed/plot/syntax.rkt
Normal file
|
@ -0,0 +1,43 @@
|
|||
#lang typed/racket
|
||||
|
||||
;; This currently does nothing useful with `->*' types
|
||||
;; TODO: make it do something useful after Vincent fixes PR 13354
|
||||
|
||||
(require (for-syntax racket/base
|
||||
racket/list))
|
||||
|
||||
(provide require/typed*)
|
||||
|
||||
(define-for-syntax (list-accum lst)
|
||||
(for/list ([i (in-range (+ 1 (length lst)))])
|
||||
(take lst i)))
|
||||
|
||||
(define-for-syntax (interpret-opts stx)
|
||||
(let loop ([stxs (syntax->list stx)] [opts empty] [kws empty])
|
||||
(cond [(empty? stxs) #`(#,(list-accum (reverse opts)) #,(reverse kws))]
|
||||
[else
|
||||
(syntax-case (first stxs) ()
|
||||
[[kw T]
|
||||
(keyword? (syntax->datum #'kw))
|
||||
(loop (rest stxs) opts (cons (first stxs) kws))]
|
||||
[_
|
||||
(loop (rest stxs) (cons (first stxs) opts) kws)])])))
|
||||
|
||||
(define-for-syntax (interpret-clause stx)
|
||||
(syntax-case stx ()
|
||||
[[name ((Rs ...) (opts ...) arrow T)]
|
||||
(and (identifier? #'arrow) (eq? '->* (syntax->datum #'arrow)))
|
||||
(syntax/loc stx
|
||||
[name (Rs ... opts ... -> T)])
|
||||
#;
|
||||
(with-syntax ([(((Os ...) ...) (Ks ...)) (interpret-opts #'(opts ...))])
|
||||
(quasisyntax/loc stx
|
||||
[name (case-> (Rs ... Os ... Ks ... -> T) ...)]))]
|
||||
[_ stx]))
|
||||
|
||||
(define-syntax (require/typed* stx)
|
||||
(syntax-case stx ()
|
||||
[(_ module-name clause ...)
|
||||
(with-syntax ([(clause ...) (map interpret-clause (syntax->list #'(clause ...)))])
|
||||
(syntax/loc stx
|
||||
(require/typed module-name clause ...)))]))
|
38
collects/typed/plot/utils.rkt
Normal file
38
collects/typed/plot/utils.rkt
Normal file
|
@ -0,0 +1,38 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
;; The commented-out module paths are those that don't exist yet
|
||||
|
||||
(require "common/types.rkt"
|
||||
;"common/marching-squares.rkt"
|
||||
;"common/marching-cubes.rkt"
|
||||
"contracted/parameters.rkt"
|
||||
"contracted/math.rkt"
|
||||
"contracted/axis-transform.rkt"
|
||||
"contracted/ticks.rkt"
|
||||
"contracted/format.rkt"
|
||||
"contracted/draw.rkt"
|
||||
"contracted/sample.rkt" ; incomplete
|
||||
;"contracted/samplers.rkt"
|
||||
;"contracted/legend.rkt"
|
||||
;"contracted/plot-element.rkt"
|
||||
"contracted/date-time.rkt"
|
||||
"contracted/kde.rkt"
|
||||
)
|
||||
|
||||
(provide (all-from-out
|
||||
"common/types.rkt"
|
||||
;"common/marching-squares.rkt"
|
||||
;"common/marching-cubes.rkt"
|
||||
"contracted/parameters.rkt"
|
||||
"contracted/math.rkt"
|
||||
"contracted/axis-transform.rkt"
|
||||
"contracted/ticks.rkt"
|
||||
"contracted/format.rkt"
|
||||
"contracted/draw.rkt"
|
||||
"contracted/sample.rkt" ; incomplete
|
||||
;"contracted/samplers.rkt"
|
||||
;"contracted/legend.rkt"
|
||||
;"contracted/plot-element.rkt"
|
||||
"contracted/date-time.rkt"
|
||||
"contracted/kde.rkt"
|
||||
))
|
176
collects/typed/tests/typed-plot-tests.rkt
Normal file
176
collects/typed/tests/typed-plot-tests.rkt
Normal file
|
@ -0,0 +1,176 @@
|
|||
#lang typed/racket
|
||||
|
||||
(require typed/plot)
|
||||
|
||||
(define xs (build-list 1000 (λ (_) (random))))
|
||||
(define ys (build-list 1000 (λ (_) (random))))
|
||||
(define zs (build-list 1000 (λ (_) (random))))
|
||||
(define xys (map (λ: ([x : Flonum] [y : Flonum]) (vector x y 3.0)) xs ys))
|
||||
(define xyzs (map (λ: ([x : Flonum] [y : Flonum] [z : Flonum]) (vector x y z 2.0)) xs ys zs))
|
||||
|
||||
(plot (points xys #:x-min 0 #:x-max 1 #:y-min 0 #:y-max 1))
|
||||
|
||||
(plot (vector-field (λ: ([x : Real] [y : Real])
|
||||
(list x y 5.0))
|
||||
-1 1 -1 1))
|
||||
|
||||
(plot (error-bars '(#(1.0 2.0 1.0)
|
||||
#(2.0 3.0 1.0))
|
||||
#:x-min 0.75 #:x-max 2.25
|
||||
#:y-min 0.5 #:y-max 4.5))
|
||||
|
||||
(plot (lines (map (λ: ([x : Real] [y : Real]) (list x y 5.0))
|
||||
(build-list 7 (λ: ([x : Real]) x))
|
||||
(build-list 7 (λ: ([x : Real]) (sqr x))))))
|
||||
|
||||
(plot (list (parametric (λ: ([t : Real])
|
||||
(list (sin t) (cos t)))
|
||||
0 (* 2 pi))
|
||||
(polar (λ: ([θ : Real]) 1/2) 0 (* 2 pi) #:color 3)))
|
||||
|
||||
(plot (list (function (λ: ([x : Real]) (- (exp x) 1)) -1.5 1.5)
|
||||
(inverse (λ: ([x : Real]) (- (exp x) 1)) -1.5 1.5 #:color 2)
|
||||
(function (λ: ([x : Real]) x) -1.5 (- (exp 1.5) 1) #:color 0 #:style 'dot)))
|
||||
|
||||
(plot (density xs 1))
|
||||
|
||||
(plot (lines-interval
|
||||
(map (λ: ([x : Real] [y : Real]) (list x y 5.0))
|
||||
(build-list 7 (λ: ([x : Real]) x))
|
||||
(build-list 7 (λ: ([x : Real]) (sqr x))))
|
||||
(map (λ: ([x : Real] [y : Real]) (list x y 5.0))
|
||||
(build-list 7 (λ: ([x : Real]) x))
|
||||
(build-list 7 (λ: ([x : Real]) (* 2 (sqr x)))))))
|
||||
|
||||
(plot (parametric-interval
|
||||
(λ: ([t : Real]) (list (sin t) (cos t)))
|
||||
(λ: ([t : Real]) (list (* 0.5 (sin t)) (* 0.5 (cos t))))
|
||||
0 (* 2 pi)))
|
||||
|
||||
(plot (polar-interval
|
||||
(λ: ([t : Real]) 1)
|
||||
(λ: ([t : Real]) 0.5)
|
||||
0 (* 2 pi)
|
||||
#:color 2
|
||||
#:style 'cross-hatch
|
||||
#:line1-color 1
|
||||
#:line2-color 5))
|
||||
|
||||
(plot (list (function-interval sin cos -3 3)
|
||||
(inverse-interval cos sin -3 3 #:color 1 #:line1-color 1 #:line2-color 1)))
|
||||
|
||||
(plot (isoline (λ (x y) (* (sin x) (cos y))) 1/2 -6 6 -6 6))
|
||||
|
||||
(plot (contours (λ: ([x : Real] [y : Real]) (* (sin x) (cos y))) -6 6 -6 6
|
||||
#:levels '(-2/3 -1/3 0 1/3 2/3)
|
||||
#:colors '(0 1 2)
|
||||
#:alphas '(0.5 1.0)))
|
||||
|
||||
(plot (contour-intervals
|
||||
(λ: ([x : Real] [y : Real]) (* (sin x) (cos y))) -6 6 -6 6
|
||||
#:levels '(-2/3 -1/3 0 1/3 2/3)
|
||||
#:colors '(0 1 2)
|
||||
#:alphas '(0.5 1.0)))
|
||||
|
||||
(plot (rectangles (list (list (ivl 0 1) (ivl 0 1))))
|
||||
#:x-min -1 #:x-max 2 #:y-min -1 #:y-max 2)
|
||||
|
||||
(plot (area-histogram (λ: ([x : Real]) (* x x x)) '(-4 -3 -2 -1 0 1 2 3 4)
|
||||
#:y-min -44))
|
||||
|
||||
(plot (discrete-histogram
|
||||
(list '(a 4)
|
||||
'(b 10)
|
||||
(list 'c (ivl 1 7)))))
|
||||
|
||||
(plot (stacked-histogram
|
||||
(list '(a (4 2 1 5))
|
||||
'(b #(10 1 1 2)))
|
||||
#:colors (λ: ([n : Natural]) (build-list n (λ: ([n : Index]) n)))
|
||||
#:styles (λ: ([n : Natural]) (build-list n (λ: ([n : Index]) n)))
|
||||
#:line-colors (λ: ([n : Natural]) (build-list n (λ: ([n : Index]) n)))
|
||||
#:line-widths (λ: ([n : Natural]) (build-list n (λ: ([n : Index]) n)))
|
||||
#:line-styles (λ: ([n : Natural]) (build-list n (λ: ([n : Index]) n)))
|
||||
#:labels '("One" "Two" "Three" "Four")))
|
||||
|
||||
(plot (list (function sin -4 4) (x-axis 1) (y-axis -1))
|
||||
#:y-min -4 #:y-max 4)
|
||||
|
||||
(plot (list (function sin -4 4) (axes 0 0))
|
||||
#:y-min -4 #:y-max 4)
|
||||
|
||||
(plot (list
|
||||
(polar-axes)
|
||||
(polar-interval
|
||||
(λ: ([t : Real]) 1)
|
||||
(λ: ([t : Real]) 0.5)
|
||||
0 (* 2 pi)
|
||||
#:color 2
|
||||
#:style 'cross-hatch
|
||||
#:line1-color 1
|
||||
#:line2-color 5)))
|
||||
|
||||
(plot (list (x-tick-lines) (y-tick-lines) (function sin -4 4)))
|
||||
|
||||
(plot (list (tick-grid) (function sin -4 4)))
|
||||
|
||||
(plot (list (function sin -4 4)
|
||||
(point-label #(1/2 1/2) "one-half, one-half")))
|
||||
|
||||
(plot (list (parametric (λ: ([t : Real]) (list (sin t) (cos t))) 0 (* 2 pi))
|
||||
(parametric-label (λ: ([t : Real]) (list (sin t) (cos t))) 0.4 #f)
|
||||
(polar (λ: ([θ : Real]) 1/2) 0 (* 2 pi) #:color 3)
|
||||
(polar-label (λ: ([θ : Real]) 1/2) 0.4 "0.4")))
|
||||
|
||||
(plot (list (function-interval sin cos -3 3)
|
||||
(function-label sin -2 #f)
|
||||
(inverse-interval cos sin -3 3 #:color 1 #:line1-color 1 #:line2-color 1)
|
||||
(inverse-label cos -2 #f)))
|
||||
|
||||
(plot3d (surface3d (λ: ([x : Real] [y : Real]) (* (sin x) (cos y))) -6 6 -6 6))
|
||||
|
||||
(plot3d (for/list: : (Listof renderer3d) ([z '(-2/3 -1/3 0 1/3 2/3)])
|
||||
(isoline3d (λ: ([x : Real] [y : Real]) (* (sin x) (cos y))) z -6 6 -6 6
|
||||
#:z-min -1 #:z-max 1)))
|
||||
|
||||
(plot3d (contours3d (λ: ([x : Real] [y : Real]) (* (sin x) (cos y))) -6 6 -6 6))
|
||||
|
||||
(plot3d (contour-intervals3d (λ: ([x : Real] [y : Real]) (* (sin x) (cos y))) -6 6 -6 6))
|
||||
|
||||
(plot3d (lines3d (map (λ: ([x : Real] [y : Real] [z : Real]) (list x y z 2.2))
|
||||
(build-list 7 (λ: ([x : Real]) x))
|
||||
(build-list 7 (λ: ([x : Real]) (sqr x)))
|
||||
(build-list 7 (λ: ([x : Real]) (* x x x))))))
|
||||
|
||||
(plot3d (parametric3d (λ: ([t : Real])
|
||||
(list (sin t) (cos t) t))
|
||||
0 (* 4 pi)))
|
||||
|
||||
(plot3d (points3d xyzs #:x-min 0 #:x-max 1 #:y-min 0 #:y-max 1 #:z-min 0 #:z-max 1))
|
||||
|
||||
(plot3d (vector-field3d (λ: ([x : Real] [y : Real] [z : Real])
|
||||
(list x y z 5.0))
|
||||
-1 1 -1 1 -1 1))
|
||||
|
||||
(plot3d (isosurface3d (λ: ([x : Real] [y : Real] [z : Real])
|
||||
(* (sin x) (cos y) (sin z)))
|
||||
1/2 -3 3 -3 3 -3 3))
|
||||
|
||||
(plot3d (isosurfaces3d (λ: ([x : Real] [y : Real] [z : Real])
|
||||
(* (sin x) (cos y) (sin z)))
|
||||
-3 3 -3 3 -3 3))
|
||||
|
||||
(plot3d (polar3d (λ: ([θ : Real] [ρ : Real]) 1)))
|
||||
|
||||
(plot3d (rectangles3d (list (list (ivl -1 1) (ivl -1 1) (ivl -1 1)))
|
||||
#:x-min -2 #:x-max 2 #:y-min -2 #:y-max 2 #:z-min -2 #:z-max 2))
|
||||
|
||||
(plot3d (discrete-histogram3d
|
||||
(list (list 'a 'a 4)
|
||||
(list 'a 'b 5)
|
||||
(list 'b 'b (ivl 1 3)))))
|
||||
|
||||
(plot3d (stacked-histogram3d
|
||||
(list (list 'a 'a '(4 1 2))
|
||||
(list 'a 'b '(5 2 1))
|
||||
(list 'b 'b '(2 3 2)))))
|
Loading…
Reference in New Issue
Block a user