From 700765abb28526e3cc3e81da4fd3a5acc1b7043f Mon Sep 17 00:00:00 2001 From: Neil Toronto Date: Tue, 22 Nov 2011 17:43:28 -0700 Subject: [PATCH] Plot label renderers now use tick settings to format coordinates --- collects/plot/plot2d/decoration.rkt | 13 ++++--------- collects/plot/tests/tick-tests.rkt | 4 ++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/collects/plot/plot2d/decoration.rkt b/collects/plot/plot2d/decoration.rkt index a05d06428d..bc4355178c 100644 --- a/collects/plot/plot2d/decoration.rkt +++ b/collects/plot/plot2d/decoration.rkt @@ -197,17 +197,12 @@ ;; =================================================================================================== ;; Labeled points -(define (format-x-coordinate x area) - (match-define (vector (ivl x-min x-max) y-ivl) (send area get-bounds-rect)) - (format "~a" (real->plot-label x (digits-for-range x-min x-max)))) - -(define (format-y-coordinate y area) - (match-define (vector x-ivl (ivl y-min y-max)) (send area get-bounds-rect)) - (format "~a" (real->plot-label y (digits-for-range y-min y-max)))) - (define (format-coordinate v area) (match-define (vector x y) v) - (format "(~a,~a)" (format-x-coordinate x area) (format-y-coordinate y area))) + (match-define (vector (ivl x-min x-max) (ivl y-min y-max)) (send area get-bounds-rect)) + (match-define (list x-str) ((ticks-format (plot-x-ticks)) x-min x-max (list (pre-tick x #t)))) + (match-define (list y-str) ((ticks-format (plot-y-ticks)) y-min y-max (list (pre-tick y #t)))) + (format "(~a,~a)" x-str y-str)) (define ((label-render-proc label v color size family anchor angle point-size alpha) area) (let ([label (if label label (format-coordinate v area))]) diff --git a/collects/plot/tests/tick-tests.rkt b/collects/plot/tests/tick-tests.rkt index 8ce19a7e00..ada896ea20 100644 --- a/collects/plot/tests/tick-tests.rkt +++ b/collects/plot/tests/tick-tests.rkt @@ -191,3 +191,7 @@ #:y-min -25 #:x-label "Time" #:y-label "Temp." #:title "Temp./Time With Applied Heat (Measurement and Trend)"))) +(parameterize ([plot-x-ticks (fraction-ticks)] + [plot-y-ticks (currency-ticks)]) + (plot (list (function sin -4 4) + (function-label sin 1/3))))