Plot now supports the option Axes.
This commit is contained in:
parent
cd67ae6633
commit
eb39b34a3b
|
@ -830,7 +830,10 @@
|
|||
List->Set
|
||||
Define
|
||||
Range
|
||||
Plot)
|
||||
Plot
|
||||
; Plot options:
|
||||
Axes
|
||||
)
|
||||
|
||||
;;;
|
||||
;;; INVARIANT
|
||||
|
@ -1182,6 +1185,8 @@
|
|||
; TODO: Improve this
|
||||
(eval u ns))
|
||||
|
||||
; Plot options:
|
||||
(define Axes 'Axes)
|
||||
(define (Plot f range [options '(List)])
|
||||
; TODO: Implement options
|
||||
;(displayln (list f range))
|
||||
|
@ -1190,18 +1195,19 @@
|
|||
(define excluded? #f)
|
||||
; TODO: plot2d needs to be extended to multiple functions
|
||||
#;(define fs
|
||||
(match functions
|
||||
(match functions
|
||||
[(List: f ...) f]
|
||||
[f (list f)]
|
||||
[else (error 'Plot "TODO")]))
|
||||
(define fs (list f))
|
||||
(define axes? (Member? Axes options))
|
||||
(match range
|
||||
[(List: var x-min x-max)
|
||||
; TODO: Declare var as a local variable ?
|
||||
(plot2d (if (procedure? f)
|
||||
(λ (x) (f x))
|
||||
(λ (x) (f x))
|
||||
(λ (x) (N (Substitute f (Equal var x)))))
|
||||
x-min x-max y-min y-max excluded?)]
|
||||
x-min x-max y-min y-max excluded? axes?)]
|
||||
[else (error)]))
|
||||
|
||||
#;(and (real? x-min) (real? x-max) (real? y-min) (real? y-max)
|
||||
|
|
|
@ -144,7 +144,10 @@
|
|||
(loop more (list x2) (cons (reverse (cons x1 ys)) xss))
|
||||
(loop (cons x2 more) (cons x1 ys) xss))])))
|
||||
|
||||
(define (plot2d unwrapped-f [x-min -5] [x-max 5] [y-min -5] [y-max 5] [excluded? #f])
|
||||
(define (cons-if bool x xs)
|
||||
(if bool (cons x xs) xs))
|
||||
|
||||
(define (plot2d unwrapped-f [x-min -5] [x-max 5] [y-min -5] [y-max 5] [excluded? #f] [axes? #t])
|
||||
; wrap the function to be drawn, s.t. it
|
||||
; returns #f in error situations
|
||||
(define (excluded-from-domain? x)
|
||||
|
@ -191,13 +194,15 @@
|
|||
; for visual comparision.
|
||||
|
||||
(if *debug*
|
||||
(begin
|
||||
(begin
|
||||
(displayln
|
||||
(list
|
||||
(begin0
|
||||
(plot (list (map lines
|
||||
(map remove-non-numbers
|
||||
connected-points)))
|
||||
(plot (list
|
||||
(cons-if axes? (axes)
|
||||
(map lines
|
||||
(map remove-non-numbers
|
||||
connected-points))))
|
||||
#:x-min x-min #:x-max x-max
|
||||
#:y-min y-min #:y-max y-max)
|
||||
(displayln (format "adaptive number of evaluations: ~a" count))
|
||||
|
@ -209,9 +214,11 @@
|
|||
(reset-count))
|
||||
|
||||
|
||||
(plot (list (map lines
|
||||
(map remove-non-numbers
|
||||
connected-points)))
|
||||
(plot (list
|
||||
(cons-if axes? (axes)
|
||||
(map lines
|
||||
(map remove-non-numbers
|
||||
connected-points))))
|
||||
#:x-min x-min #:x-max x-max
|
||||
#:y-min y-min #:y-max y-max)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user