Skip to content

@RayRacine /gist:3315984
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
TR Bug
#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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.