public
Created

TR Bug

  • Download Gist
gistfile1.rkt
Racket
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
#lang typed/racket/base
 
(require
(only-in racket/math
sqr))
 
(define-type Color% (Class () () ()))
 
(define-type Labels
(U (Listof (Option String))
((Listof Any) -> (Listof (Option String)))))
 
(define-type Alphas
(U (Listof Real)
((Listof Any) -> (Listof Real))))
 
(define-type Plot-Brush-Style
(U Integer 'transparent 'solid
'bdiagonal-hatch 'fdiagonal-hatch 'crossdiag-hatch
'horizontal-hatch 'vertical-hatch 'cross-hatch))
 
(define-type Plot-Brush-Styles
(U (Listof Plot-Pen-Style)
((Listof Any) -> (Listof Plot-Pen-Style))))
 
(define-type Plot-Pen-Style
(U Integer 'transparent 'solid
'bdiagnol-hatch 'fdiagonal-hatch
'horizontal-hath 'veritcal-hatch
'crossdisg-hatch 'cross-hatch))
 
(define-type (Plot-Pen-Styles A)
(U (Listof Plot-Pen-Style)
((Listof A) -> (Listof Plot-Pen-Style))))
 
(define-type (Pen-Widths A) (U (Listof Plot-Pen-Style)
((Listof A) -> (Listof Plot-Pen-Style))))
 
 
(define-type Plot-Color (U Integer (List Real Real Real)
String Symbol Color%))
 
(define-type (Plot-Colors A) (U (Listof Plot-Color)
((Listof A) -> (Listof Plot-Color))))
 
(define-type Image-Snip% (Class () () ()))
 
(require/typed plot/utils
[opaque Renderer2d renderer2d?]
[linear-seq (Real Real Exact-Nonnegative-Integer -> (Listof Real))])
 
(require/typed plot/main
[plot (Any -> Any)]
[opaque Interval ivl?]
[ivl (Real Real -> Interval)]
[rectangles ((Listof (Vector Interval Interval))
[#:x-min (Option Exact-Rational)]
[#:x-max (Option Exact-Rational)]
[#:y-min (Option Exact-Rational)]
[#:y-max (Option Exact-Rational)]
[#:color Plot-Color]
[#:style Plot-Brush-Style]
[#:line-color Plot-Color]
[#:line-width Plot-Brush-Style]
[#:line-style Plot-Pen-Style]
[#:alpha Real]
[#:label (Option String)]
-> Renderer2d)]
;; TR does not support KW and optional args.
[function ((Real -> Real)
(Option Exact-Rational)
(Option Exact-Rational)
[#:y-min Exact-Rational]
[#:y-max Exact-Rational]
[#:samples Integer]
[#:color Plot-Color]
[#:width Real]
[#:style Plot-Pen-Style]
[#:alpha Real]
[#:label (Option String)]
-> Renderer2d)]
[area-histogram ((Real -> Real)
(Listof Real)
[#:x-min (Option Exact-Rational)]
[#:x-max (Option Exact-Rational)]
[#:y-min (Option Exact-Rational)]
[#:y-max (Option Exact-Rational)]
[#:samples Integer]
[#:color Plot-Color]
[#:style Plot-Brush-Style]
[#:line-color Plot-Color]
[#:line-width Plot-Brush-Style]
[#:line-style Plot-Pen-Style]
[#:alpha Real]
[#:label (Option String)]
-> Renderer2d)]
[discrete-histogram ((Listof (Vector Any (Option (U Real Interval))))
[#:x-min (Option Exact-Rational)]
[#:x-max (Option Exact-Rational)]
[#:y-min (Option Exact-Rational)]
[#:y-max (Option Exact-Rational)]
[#:gap Real]
[#:skip Real]
[#:invert? Boolean]
[#:color Plot-Color]
[#:style Plot-Brush-Style]
[#:line-color Plot-Color]
[#:line-width Plot-Brush-Style]
[#:line-style Plot-Pen-Style]
[#:alpha Real]
[#:label (Option String)]
[#:add-ticks? Boolean]
[#:far-ticks? Boolean]
-> Renderer2d)]
[stacked-histogram ((Listof (Vector Any (Listof Real)))
[#:x-min (Option Exact-Rational)]
[#:x-max (Option Exact-Rational)]
[#:y-min (Option Exact-Rational)]
[#:y-max (Option Exact-Rational)]
[#:gap Real]
[#:skip Real]
[#:invert? Boolean]
[#:colors Plot-Colors]
[#:styles Plot-Brush-Styles]
[#:line-colors Plot-Colors]
[#:line-widths Pen-Widths]
[#:line-styles Plot-Pen-Styles]
[#:alphas (U Alphas Natural)]
[#:labels (U Labels Natural)]
[#:add-ticks? Boolean]
[#:far-ticks? Boolean]
-> (Listof Renderer2d))])
 
(define (test)
(: f (Real -> Real))
(define (f x) (exp (* -1/2 (sqr x))))
(plot (list (area-histogram f (linear-seq -4 4 10)
#:label "Root 2")
(function f -4 4))))
 
 
(define (test2)
(plot (discrete-histogram (list #(A 1.0) #(B 2.0) #(B 3.0)
(vector 'C (ivl 0.5 1.5)))
#:label "Hello")))
 
;(define (test3)
; (plot (list (discrete-histogram
; '(#(Eggs 1.5) #(Bacon 2.5) #(Pancakes 3.5))
; #:skip 2.5 #:x-min 0
; #:label "AMD")
; (discrete-histogram
; '(#(Eggs 1.4) #(Bacon 2.3) #(Pancakes 3.1))
; #:skip 2.5 #:x-min 1
; #:label "Intel" #:color 2 #:line-color 2))
; #:x-label "Breakfast Food" #:y-label "Cooking Time (minutes)"
; #:title "Cooking Times For Breakfast Food, Per Processor"))
;
;(define (test4)
; (plot (stacked-histogram (list #(a (1 1 1)) #(b (1.5 3))
; #(c ()) #(d (1/2)))
; #:invert? #t)))
; #:labels '("Red" #f "Blue"))
; #:legend-anchor 'top-right))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.