Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions plot-doc/plot/scribblings/params.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ When any of these is @racket[#f], the corresponding axis is not drawn.
Use these along with @racket[x-axis] and @racket[y-axis] renderers if you want axes that intersect the origin or some other point.
}

@deftogether[((defparam plot-x-tick-labels? draw? boolean? #:value #t)
(defparam plot-y-tick-labels? draw? boolean? #:value #t)
(defparam plot-z-tick-labels? draw? boolean? #:value #t)
(defparam plot-x-far-tick-labels? draw? boolean? #:value #f)
(defparam plot-y-far-tick-labels? draw? boolean? #:value #f)
(defparam plot-z-far-tick-labels? draw? boolean? #:value #f))]{
When any of these is @racket[#f], the corresponding labels for the ticks on the axis are not drawn.
These parameters work together with the parameters like @racket[plot-x-axis?] that control the drawing of the axes; i.e. tick labels won't be drawn unless the axis itself is drawn.
}

@defparam[plot-animating? animating? boolean? #:value #f]{
When @(racket #t), certain renderers draw simplified plots to speed up drawing.
@(plot-name) sets it to @(racket #t), for example, when a user is clicking and dragging a 3D plot to rotate it.
Expand Down
8 changes: 6 additions & 2 deletions plot-lib/plot/private/common/parameter-groups.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
plot-z-axis? plot-z-far-axis?))

(define-parameter-group plot-tick-labels
(plot-x-tick-label-anchor
(plot-x-tick-labels?
plot-x-tick-label-anchor
plot-x-tick-label-angle
plot-x-far-tick-labels?
plot-x-far-tick-label-anchor
plot-x-far-tick-label-angle
plot-y-tick-labels?
plot-y-tick-label-anchor
plot-y-tick-label-angle
plot-y-far-tick-labels?
plot-y-far-tick-label-anchor
plot-y-far-tick-label-angle))

Expand Down Expand Up @@ -89,7 +93,7 @@
Anchor
Nonnegative-Real
(List Boolean Boolean Boolean Boolean Boolean Boolean)
(List Anchor Real Anchor Real Anchor Real Anchor Real)
(List Boolean Anchor Real Boolean Anchor Real Boolean Anchor Real Boolean Anchor Real)
Boolean
Boolean)
(List Positive-Integer Real Real Nonnegative-Real Boolean Boolean)
Expand Down
8 changes: 8 additions & 0 deletions plot-lib/plot/private/common/parameters.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@
(defparam plot-y-far-axis? Boolean #t)
(defparam plot-z-far-axis? Boolean #t)

(defparam plot-x-tick-labels? Boolean #t)
(defparam plot-y-tick-labels? Boolean #t)
(defparam plot-z-tick-labels? Boolean #t)

(defparam plot-x-far-tick-labels? Boolean #f)
(defparam plot-y-far-tick-labels? Boolean #f)
(defparam plot-z-far-tick-labels? Boolean #f)

(defparam2 plot-x-tick-label-angle angle Real Real 0 (rational 'plot-x-tick-label-angle))
(defparam2 plot-y-tick-label-angle angle Real Real 0 (rational 'plot-y-tick-label-angle))
(defparam2 plot-x-far-tick-label-angle angle Real Real 0 (rational 'plot-x-far-tick-label-angle))
Expand Down
16 changes: 10 additions & 6 deletions plot-lib/plot/private/plot2d/plot-area.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,14 @@
;; -----------------------------------------------------------------------------------------------
;; Tick label parameters

(: draw-x-tick-labels? Boolean)
(: draw-y-tick-labels? Boolean)
(: draw-x-far-tick-labels? Boolean)
(: draw-y-far-tick-labels? Boolean)
(define draw-x-far-tick-labels? (not (and (plot-x-axis?) (equal? x-ticks x-far-ticks))))
(define draw-y-far-tick-labels? (not (and (plot-y-axis?) (equal? y-ticks y-far-ticks))))
(define draw-x-tick-labels? (plot-x-tick-labels?))
(define draw-y-tick-labels? (plot-y-tick-labels?))
(define draw-x-far-tick-labels? (or (plot-x-far-tick-labels?) (not (and (plot-x-axis?) (equal? x-ticks x-far-ticks)))))
(define draw-y-far-tick-labels? (or (plot-y-far-tick-labels?) (not (and (plot-y-axis?) (equal? y-ticks y-far-ticks)))))

(: x-tick-label-offset (Vectorof Real))
(: y-tick-label-offset (Vectorof Real))
Expand All @@ -355,7 +359,7 @@

(: get-x-tick-label-params (-> (Listof Label-Params)))
(define (get-x-tick-label-params)
(if (plot-x-axis?)
(if (and (plot-x-axis?) draw-x-tick-labels?)
(get-tick-label-params x-ticks
x-tick-label-offset
(λ ([x : Real]) (x-tick-value->dc x))
Expand All @@ -365,7 +369,7 @@

(: get-y-tick-label-params (-> (Listof Label-Params)))
(define (get-y-tick-label-params)
(if (plot-y-axis?)
(if (and (plot-y-axis?) draw-y-tick-labels?)
(get-tick-label-params y-ticks
y-tick-label-offset
(λ ([y : Real]) (y-tick-value->dc y))
Expand Down Expand Up @@ -423,14 +427,14 @@

(: max-x-tick-label-height Real)
(define max-x-tick-label-height
(if (plot-x-axis?)
(if (and (plot-x-axis?) draw-x-tick-labels?)
(apply max 0 (map (λ ([corner : (Vectorof Real)]) (vector-ref corner 1))
(get-relative-corners (get-x-tick-label-params))))
0))

(: max-y-tick-label-width Real)
(define max-y-tick-label-width
(if (plot-y-axis?)
(if (and (plot-y-axis?) draw-y-tick-labels?)
(- (apply min 0 (map (λ ([corner : (Vectorof Real)]) (vector-ref corner 0))
(get-relative-corners (get-y-tick-label-params)))))
0))
Expand Down
24 changes: 15 additions & 9 deletions plot-lib/plot/private/plot3d/plot-area.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,19 @@

;; -----------------------------------------------------------------------------------------------
;; Tick label parameters


(: draw-x-tick-labels? Boolean)
(: draw-y-tick-labels? Boolean)
(: draw-z-tick-labels? Boolean)
(: draw-x-far-tick-labels? Boolean)
(: draw-y-far-tick-labels? Boolean)
(: draw-z-far-tick-labels? Boolean)
(define draw-x-far-tick-labels? (not (and (plot-x-axis?) (equal? x-ticks x-far-ticks))))
(define draw-y-far-tick-labels? (not (and (plot-y-axis?) (equal? y-ticks y-far-ticks))))
(define draw-z-far-tick-labels? (not (and (plot-z-axis?) (equal? z-ticks z-far-ticks))))
(define draw-x-tick-labels? (plot-x-tick-labels?))
(define draw-y-tick-labels? (plot-y-tick-labels?))
(define draw-z-tick-labels? (plot-z-tick-labels?))
(define draw-x-far-tick-labels? (or (plot-x-far-tick-labels?) (not (and (plot-x-axis?) (equal? x-ticks x-far-ticks)))))
(define draw-y-far-tick-labels? (or (plot-y-far-tick-labels?) (not (and (plot-y-axis?) (equal? y-ticks y-far-ticks)))))
(define draw-z-far-tick-labels? (or (plot-z-far-tick-labels?) (not (and (plot-z-axis?) (equal? z-ticks z-far-ticks)))))

(: sort-ticks (-> (Listof tick) (-> Real FlVector) (Listof tick)))
(define/private (sort-ticks ts tick-value->view)
Expand Down Expand Up @@ -627,7 +633,7 @@

(: get-x-tick-label-params (-> (Listof Label-Params)))
(define (get-x-tick-label-params)
(if (plot-x-axis?)
(if (and (plot-x-axis?) draw-x-tick-labels?)
(let ([offset (if x-axis-y-min? (vneg (y-axis-dir)) (y-axis-dir))])
(get-tick-label-params (sort-ticks x-ticks (λ ([x : Real]) (x-tick-value->view x)))
(λ ([x : Real]) (x-tick-value->dc x))
Expand All @@ -637,7 +643,7 @@

(: get-y-tick-label-params (-> (Listof Label-Params)))
(define (get-y-tick-label-params)
(if (plot-y-axis?)
(if (and (plot-y-axis?) draw-y-tick-labels?)
(let ([offset (if y-axis-x-min? (vneg (x-axis-dir)) (x-axis-dir))])
(get-tick-label-params (sort-ticks y-ticks (λ ([y : Real]) (y-tick-value->view y)))
(λ ([y : Real]) (y-tick-value->dc y))
Expand All @@ -647,7 +653,7 @@

(: get-z-tick-label-params (-> (Listof Label-Params)))
(define (get-z-tick-label-params)
(if (plot-z-axis?)
(if (and (plot-z-axis?) draw-z-tick-labels?)
(get-tick-label-params z-ticks
(λ ([z : Real]) (z-tick-value->dc z))
#(-1 0)
Expand Down Expand Up @@ -745,13 +751,13 @@

(: max-x-tick-label-diag (-> Real))
(define (max-x-tick-label-diag)
(if (plot-x-axis?)
(if (and (plot-x-axis?) draw-x-tick-labels?)
(max-tick-label-diag (y-axis-dir) max-x-tick-label-width max-x-tick-label-height)
0))

(: max-y-tick-label-diag (-> Real))
(define (max-y-tick-label-diag)
(if (plot-y-axis?)
(if (and (plot-y-axis?) draw-y-far-tick-labels?)
(max-tick-label-diag (x-axis-dir) max-y-tick-label-width max-y-tick-label-height)
0))

Expand Down
6 changes: 6 additions & 0 deletions plot-lib/plot/private/utils-and-no-gui.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
plot-x-far-axis?
plot-y-far-axis?
plot-z-far-axis?
plot-x-tick-labels?
plot-y-tick-labels?
plot-z-tick-labels?
plot-x-far-tick-labels?
plot-y-far-tick-labels?
plot-z-far-tick-labels?
plot-x-tick-label-anchor
plot-y-tick-label-anchor
plot-x-far-tick-label-anchor
Expand Down