racket/collects/plot/tests/tick-tests.rkt
Neil Toronto afadbbf0d1 Parameter lists
Some tick changes
Allow #f in renderer fields
2011-11-10 12:59:41 -07:00

102 lines
4.0 KiB
Racket

#lang racket
(require plot (only-in plot/common/math floor-log/base real-modulo))
(plot-font-family 'swiss)
(plot (function (λ (x) (count pre-tick-major? ((linear-ticks) 0 x 8 id-transform)))
0.1 10))
(plot (function (λ (x) (count pre-tick-major? ((linear-ticks) 0 x 40 id-transform)))
1 100))
(parameterize ([plot-x-ticks (linear-ticks #:base 2 #:divisors '(1 2))]
#;[plot-y-ticks (linear-ticks #:base (* 1 2 3 4 5) #:divisors '(1 2 3 4 5))])
(plot (function cos 0.013 2.1176)))
(parameterize ([plot-x-transform log-transform]
[plot-x-ticks (ticks (log-ticks-layout)
(fraction-ticks-format))]
[plot-y-ticks (fraction-ticks)])
(plot (function (λ (x) (+ 1 (cos x))) 0.0001 12)))
(parameterize ([plot-x-ticks (date-ticks)]
[plot-x-max-ticks 3]
[plot-y-ticks (currency-ticks)])
(plot (function values -1 1)))
(currency-ticks-formats uk-currency-formats)
(currency-ticks-scales uk-currency-scales)
(parameterize ([plot-x-ticks (date-ticks)]
[plot-y-ticks (currency-ticks #:kind 'GBP)])
(plot (function values 101232512 2321236192)))
(currency-ticks-formats eu-currency-formats)
(currency-ticks-scales eu-currency-scales)
(parameterize ([plot-x-ticks (currency-ticks #:kind 'EUR)]
[plot-y-ticks (currency-ticks)])
(plot (function (λ (x) (* x 1.377)) 8000000 10000000)
#:title "EUR-USD Conversion, 2011-10-13"
#:x-label "Euros"
#:y-label "Dollars"))
(parameterize ([plot-x-ticks (no-ticks)])
(plot (function sin -1 4)))
(parameterize ([plot-x-transform log-transform]
[plot-y-transform log-transform]
[plot-x-ticks (log-ticks #:base 10)]
[plot-y-ticks (log-ticks #:base 2)])
(plot (function values 0.1 10)))
(parameterize ([plot-x-transform log-transform]
[plot-y-transform (stretch-transform -1 1 4)]
[plot-x-ticks (ticks (uniform-ticks-layout)
(log-ticks-format #:base 10))]
[plot-y-ticks (ticks (uniform-ticks-layout)
(currency-ticks-format #:kind 'USD))])
(plot (function log 0.1 10)))
(parameterize ([plot-x-transform log-transform]
[plot-x-ticks (log-ticks #:base 10)])
(plot (function values 10000000000000 1000000000000000)))
(plot (polar-axes) #:x-min -1 #:x-max 1 #:y-min -1 #:y-max 1)
(plot (polar-axes) #:x-min 0 #:x-max 3 #:y-min 0 #:y-max 3)
(plot (polar-axes) #:x-min 1 #:x-max 4 #:y-min 1 #:y-max 4)
(plot (polar-axes #:number 12) #:x-min 10 #:x-max 12 #:y-min 10 #:y-max 12)
(parameterize ([plot-z-transform log-transform]
[plot-z-ticks (log-ticks)]
[contour-samples (plot3d-samples)])
(values
(plot (contours (λ (x y) (exp (- (+ (sqr x) (sqr y))))) -2 2 -2 2 #:label "z"))
(plot (contour-intervals (λ (x y) (exp (- (+ (sqr x) (sqr y))))) -2 2 -2 2 #:label "z"))
(plot3d (contours3d (λ (x y) (exp (- (+ (sqr x) (sqr y))))) -2 2 -2 2 #:label "z"))
(plot3d (contour-intervals3d (λ (x y) (exp (- (+ (sqr x) (sqr y))))) -2 2 -2 2 #:label "z"))))
(plot (contours (λ (x y) (* 1/2 (+ (sqr x) (sqr y)))) -1 1 -1 1 #:label "z"))
(plot3d (contours3d (λ (x y) (* 1/2 (+ (sqr x) (sqr y)))) -1 1 -1 1 #:label "z"))
(parameterize ([plot-y-ticks (ticks-scale (plot-y-ticks) (linear-scale 2 1))])
(plot (list (function sqr -2 2)
(function sin -4 4))))
(define exp-scale (invertible-function exp log))
(parameterize ([plot-y-ticks (ticks-scale (log-ticks) exp-scale)])
(plot (function values -10 10)))
(parameterize ([plot-y-ticks (ticks-add (no-ticks) '(1/3 2/3))])
(plot (function sin -4 4)))
(plot (list (function sin -4 4)
(points '(#(-3.75 -1/4)) #:size 10)
(x-ticks (list (tick 1.5 #t "3/2") (tick 3 #t "Three")))
(y-ticks (list (tick 1/4 #t "1/4") (tick -1/4 #f "")))))