Skip to content

Commit cad274d

Browse files
authored
Allow markers to be specified for function and line renderers (#118) (#120)
The #marker option for `function`, `inverse` and `line` renderers will draw markers along the rendered plot line.
1 parent 23d3c46 commit cad274d

File tree

5 files changed

+377
-37
lines changed

5 files changed

+377
-37
lines changed

plot-doc/plot/scribblings/renderer2d.scrbl

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,32 @@ Returns a renderer that draws rectangles filled with a color based on the center
226226
[#:width width (>=/c 0) (line-width)]
227227
[#:style style plot-pen-style/c (line-style)]
228228
[#:alpha alpha (real-in 0 1) (line-alpha)]
229+
[#:marker marker point-sym/c 'none]
230+
[#:marker-color marker-color (or/c 'auto plot-color/c) 'auto]
231+
[#:marker-fill-color marker-fill-color (or/c 'auto plot-color/c) 'auto]
232+
[#:marker-size marker-size (>=/c 0) (point-size)]
233+
[#:marker-line-width marker-line-width (>=/c 0) (point-line-width)]
234+
[#:marker-alpha marker-alpha (real-in 0 1) (point-alpha)]
235+
[#:marker-count marker-count positive-integer? 20]
229236
[#:label label (or/c string? pict? #f) #f]
230237
) renderer2d?]{
231-
Returns a renderer that plots a function of @italic{x}. For example, a parabola:
232-
@interaction[#:eval plot-eval (plot (function sqr -2 2))]
233238

234-
@history[#:changed "7.9" "Added support for pictures for #:label"]
239+
Returns a renderer that plots a function of @italic{x}. For example, a parabola:
240+
241+
@interaction[#:eval plot-eval (plot (function sqr -2 2))]
242+
243+
When @(racket marker) is not @racket['none], markers will be placed on the
244+
on the line drawn for the function at equal intervals. The marker and
245+
related arguments are the same as for the @racket[points] renderer. The
246+
number of markers shown on the plot is specified by @racket[marker-count]
247+
parameter.
248+
249+
Using markers has the same effect as using both a @racket[function] and a
250+
@racket[points] renderer in a single plot, exept that using @racket[marker]s
251+
will show the marker super-imposed over the line style in the plot legend.
252+
253+
@history[#:changed "7.9" "#:label argument supports pictures"]
254+
@history[#:changed "8.10" "#:marker and related arguments added"]
235255
}
236256

237257
@defproc[(inverse [f (real? . -> . real?)]
@@ -242,17 +262,30 @@ Returns a renderer that plots a function of @italic{x}. For example, a parabola:
242262
[#:width width (>=/c 0) (line-width)]
243263
[#:style style plot-pen-style/c (line-style)]
244264
[#:alpha alpha (real-in 0 1) (line-alpha)]
245-
[#:label label (or/c string? pict? #f) #f]
246-
) renderer2d?]{
247-
Like @(racket function), but regards @(racket f) as a function of @italic{y}.
248-
For example, a parabola, an inverse parabola, and the reflection line:
265+
[#:marker marker point-sym/c 'none]
266+
[#:marker-color marker-color (or/c 'auto plot-color/c) 'auto]
267+
[#:marker-fill-color marker-fill-color (or/c 'auto plot-color/c) 'auto]
268+
[#:marker-size marker-size (>=/c 0) (point-size)]
269+
[#:marker-line-width marker-line-width (>=/c 0) (point-line-width)]
270+
[#:marker-alpha marker-alpha (real-in 0 1) (point-alpha)]
271+
[#:marker-count marker-count positive-integer? 20]
272+
[#:label label (or/c string? pict? #f) #f]) renderer2d?]{
273+
274+
Like @(racket function), but regards @(racket f) as a function of
275+
@italic{y}. For example, a parabola, an inverse parabola, and the
276+
reflection line:
277+
249278
@interaction[#:eval plot-eval
250279
(plot (list (axes)
251280
(function sqr -2 2 #:label "y = x²")
252281
(function (λ (x) x) #:color 0 #:style 'dot #:label "y = x")
253282
(inverse sqr -2 2 #:color 3 #:label "x = y²")))]
254283

255-
@history[#:changed "7.9" "Added support for pictures for #:label"]
284+
The @(racket marker) and related arguments have the same meaning as for the
285+
@racket[function] renderer.
286+
287+
@history[#:changed "7.9" "#:label argument supports pictures"]
288+
@history[#:changed "8.10" "#:marker and related arguments added"]
256289
}
257290

258291
@defproc[(lines [vs (sequence/c (sequence/c #:min-count 2 real?))]
@@ -262,6 +295,12 @@ For example, a parabola, an inverse parabola, and the reflection line:
262295
[#:width width (>=/c 0) (line-width)]
263296
[#:style style plot-pen-style/c (line-style)]
264297
[#:alpha alpha (real-in 0 1) (line-alpha)]
298+
[#:marker marker point-sym/c 'none]
299+
[#:marker-color marker-color (or/c 'auto plot-color/c) 'auto]
300+
[#:marker-fill-color marker-fill-color (or/c 'auto plot-color/c) 'auto]
301+
[#:marker-size marker-size (>=/c 0) (point-size)]
302+
[#:marker-line-width marker-line-width (>=/c 0) (point-line-width)]
303+
[#:marker-alpha marker-alpha (real-in 0 1) (point-alpha)]
265304
[#:label label (or/c string? pict? #f) #f]
266305
[#:ignore-axis-transforms? ignore-axis-transforms? boolean? #f]
267306
) renderer2d?]{
@@ -284,6 +323,14 @@ For example, a parabola, an inverse parabola, and the reflection line:
284323
independent data sets with one @(racket lines) renderer, improving rendering
285324
performence for large datasets.
286325

326+
When @(racket marker) is not @racket['none], markers will be placed on the
327+
on the line at each point in @racket[vs]. The marker and related arguments
328+
are the same as for the @racket[points] renderer.
329+
330+
Using markers has the same effect as using both a @racket[lines] and a
331+
@racket[points] renderer in a single plot, exept that using @racket[marker]s
332+
will show the marker super-imposed over the line style in the plot legend.
333+
287334
When @(racket ignore-axis-transforms?) is @racket[#t], only the individual
288335
points in @(racket vs) are affected by axis transforms, not the lines that
289336
connect these points. This feature can be used, for example, to plot a
@@ -319,6 +366,7 @@ For example, a parabola, an inverse parabola, and the reflection line:
319366

320367
@history[#:changed "7.9" "#:label argument supports pictures"]
321368
@history[#:changed "8.9" "#:ignore-axis-transforms? argument added"]
369+
@history[#:changed "8.10" "#:marker and related arguments added"]
322370
}
323371

324372
@defproc[(parametric [f (real? . -> . (sequence/c real?))]

0 commit comments

Comments
 (0)