On this page:
8.18
top
up

43D RenderersπŸ”— i

(require plot ) package: plot-gui-lib

4.13D Renderer Function ArgumentsπŸ”— i

As with functions that return 2D renderers, functions that return 3D renderers always have these kinds of arguments:
  • Required (and possibly optional) arguments representing the graph to plot.

  • Optional keyword arguments for overriding calculated bounds, with the default value #f.

  • Optional keyword arguments that determine the appearance of the plot.

  • The optional keyword argument #:label, which specifies the name of the renderer in the legend.

See 2D Renderer Function Arguments for a detailed example.

4.23D Point RenderersπŸ”— i

procedure

( points3d vs
[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:symsym
#:colorcolor
#:fill-colorfill-color
#:x-jitterx-jitter
#:y-jittery-jitter
#:z-jitterz-jitter
#:sizesize
#:line-widthline-width
#:alphaalpha
#:labellabel])renderer3d?
vs:(sequence/c (sequence/c #:min-count3real? ))
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
fill-color:(or/c plot-color/c 'auto)='auto
x-jitter:(>=/c 0)=(point-x-jitter )
y-jitter:(>=/c 0)=(point-y-jitter )
z-jitter:(>=/c 0)=(point-z-jitter )
size:(>=/c 0)=(point-size )
line-width:(>=/c 0)=(point-line-width )
alpha:(real-in 01)=(point-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that draws points in 3D space.

For example, a scatter plot of points sampled uniformly from the surface of a sphere:
> (define (runif)(- (* 2(random ))1))
> (define (rnormish)(+ (runif)(runif)(runif)(runif)))
> (define xs0(build-list 1000(λ _ (rnormish))))
> (define ys0(build-list 1000(λ _ (rnormish))))
> (define zs0(build-list 1000(λ _ (rnormish))))
> (define mags(map (λ (xyz)(sqrt (+ (sqr x)(sqr y)(sqr z))))
xs0ys0zs0))
> (define xs(map / xs0mags))
> (define ys(map / ys0mags))
> (define zs(map / zs0mags))
> (plot3d (points3d (map vector xsyszs)#:sym'dot)
#:altitude25)

When x-jitter, y-jitter, or z-jitter is non-zero, each point p is translated along the matching axis by a random distance no greater than the given value. Jitter may be applied in either the positive or negative direction, so total spread along e.g. the x-axis is twice x-jitter.

Note that adding random noise to data, via jittering or otherwise, is usually a bad idea. See the documentation for points for examples where jittering may be appropriate.

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

[ x-min
x-max
y-min
y-max
z-min
z-max
#:samplessamples
#:scalescale
#:colorcolor
#:line-widthline-width
#:line-styleline-style
#:alphaalpha
#:labellabel])renderer3d?
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
scale : (or/c real? (one-of/c 'auto'normalized))
line-width:(>=/c 0)=(vector-field-line-width )
label:(or/c string? pict? #f)=#f
Returns a renderer that draws a vector field in 3D space. The arguments are interpreted identically to the corresponding arguments to vector-field .

Example:
> (plot3d (vector-field3d (λ (xyz)(vector xzy))
-22-22-22))

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label and controlling the arrowhead

4.33D Line RenderersπŸ”— i

procedure

( lines3d vs
[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:colorcolor
#:widthwidth
#:stylestyle
#:alphaalpha
#:labellabel])renderer3d?
vs:(sequence/c (sequence/c #:min-count3real? ))
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
width:(>=/c 0)=(line-width )
alpha:(real-in 01)=(line-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that draws connected lines. The parametric3d function is defined in terms of this one.

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

t-min
t-max
[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:samplessamples
#:colorcolor
#:widthwidth
#:stylestyle
#:alphaalpha
#:labellabel])renderer3d?
t-min:rational?
t-max:rational?
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
width:(>=/c 0)=(line-width )
alpha:(real-in 01)=(line-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that plots a vector-valued function of time. For example,
(- pi )pi #:samples3000#:alpha0.5)
#:altitude25)

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

( arrows3d vs
[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:colorcolor
#:widthwidth
#:stylestyle
#:alphaalpha
#:arrow-head-size-or-scalesize
#:arrow-head-angleangle
#:labellabel])renderer3d?
vs :
(or/c (listof (sequence/c #:min-count3real? ))
(vectorof (vector/c (sequence/c #:min-count3real? )
(sequence/c #:min-count3real? ))))
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
width:(>=/c 0)=(arrows-line-width )
alpha:(real-in 01)=(arrows-alpha )
size : (or/c (list/c '=(>=/c 0))(>=/c 0))
angle:(>=/c 0)=(arrow-head-angle )
label:(or/c string? pict? #f)=#f
Returns a renderer that draws arrows. The arguments and arrow-head parameters are interpreted identically as in arrows .
> (plot3d (arrows3d `((000)(111)(222)(321)))
#:altitude25)

Added in version 7.9 of package plot-gui-lib.

4.43D Surface RenderersπŸ”— i

procedure

( surface3d f
[ x-min
x-max
y-min
y-max
#:z-minz-min
#:z-maxz-max
#:samplessamples
#:colorcolor
#:stylestyle
#:line-colorline-color
#:line-widthline-width
#:line-styleline-style
#:alphaalpha
#:labellabel])renderer3d?
f:(real? real? . -> .real? )
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
line-width:(>=/c 0)=(surface-line-width )
alpha:(real-in 01)=(surface-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that plots a two-input, one-output function. For example,
> (plot3d (list (surface3d (λ (xy)(+ (sqr x)(sqr y)))-11-11
#:label"z = x² + y²")
(surface3d (λ (xy)(- (+ (sqr x)(sqr y))))-11-11
#:color4#:line-color4
#:label"z = -x² - y²")))

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

( polar3d f
[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:samplessamples
#:colorcolor
#:stylestyle
#:line-colorline-color
#:line-widthline-width
#:line-styleline-style
#:alphaalpha
#:labellabel])renderer3d?
f:(real? real? . -> .real? )
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
line-width:(>=/c 0)=(surface-line-width )
alpha:(real-in 01)=(surface-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that plots a function from longitude and latitude to radius. (fθϕ)r

Currently, longitudes(θ) range from 0 to (* 2pi ), and latitudes(ϕ) from (* -1/2pi ) to (* 1/2pi ). These intervals may become optional arguments to polar3d in the future.

A sphere is the graph of a polar function of constant radius:
> (plot3d (polar3d (λ (θϕ)1))#:altitude25)

Combining polar function renderers allows faking latitudes or longitudes in larger ranges, to get, for example, a seashell plot:
(define (f1θϕ)(+ 1(/ θ2pi )(* 1/8(sin (* 8ϕ)))))
(define (f2θϕ)(+ 0(/ θ2pi )(* 1/8(sin (* 8ϕ)))))
(plot3d (list (polar3d f1#:color"navajowhite"
#:line-style'transparent#:alpha2/3)
(polar3d f2#:color"navajowhite"
#:line-style'transparent#:alpha2/3))))

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

s-min
s-max
t-min
t-max
[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:samplessamples
#:s-sampless-samples
#:t-samplest-samples
#:colorcolor
#:stylestyle
#:line-colorline-color
#:line-widthline-width
#:line-styleline-style
#:alphaalpha
#:labellabel])renderer3d?
s-min:rational?
s-max:rational?
t-min:rational?
t-max:rational?
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
s-samples:(and/c exact-integer? (>=/c 2))=samples
t-samples:(and/c exact-integer? (>=/c 2))=samples
line-width:(>=/c 0)=(surface-line-width )
alpha:(real-in 01)=(surface-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that plots a two-input, one-output function. (fst)'(xyz)

For example,
> (plot3d (list
(λ (θϕ)
(list (* (+ 5(sin ϕ))(sin θ))
(* (+ 5(sin ϕ))(cos θ))
(+ 0(cos ϕ))))
0(* 2pi )#:s-samples50
0(* 2pi )
#:label"torus1")
(λ (θϕ)
(list (+ 4(* (+ 3(sin ϕ))(sin θ)))
(+ 0(cos ϕ))
(* (+ 3(sin ϕ))(cos θ))))
0(* 2pi )#:s-samples30
0(* 2pi )
#:color4
#:label"torus2"))
#:z-min-6#:z-max6
#:altitude22)

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

( polygons3d vs
[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:colorcolor
#:stylestyle
#:line-colorline-color
#:line-widthline-width
#:line-styleline-style
#:alphaalpha
#:labellabel])renderer3d?
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
line-width:(>=/c 0)=(surface-line-width )
alpha:(real-in 01)=(surface-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that draws polygons. The parametric-surface3d function is defined in terms of this one.
> (plot3d
(polygons3d (list (list (list 100)(list 001)(list 010)(list 111))
(list (list 000)(list 001)(list 010))
(list (list 100)(list 010)(list 000))))
#:angle355
#:altitude30)

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

4.53D Contour (Isoline) RenderersπŸ”— i

procedure

( isoline3d f
z
[ x-min
x-max
y-min
y-max
#:z-minz-min
#:z-maxz-max
#:samplessamples
#:colorcolor
#:widthwidth
#:stylestyle
#:alphaalpha
#:labellabel])renderer3d?
f:(real? real? . -> .real? )
z:real?
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
width:(>=/c 0)=(line-width )
alpha:(real-in 01)=(line-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that plots a single contour line on the surface of a function.

The appearance keyword arguments are interpreted identically to the appearance keyword arguments to isoline .

This function is not terribly useful by itself, but can be when combined with others:
> (define (saddlexy)(- (sqr x)(sqr y)))
> (plot3d (list (surface3d saddle-11-11)
(isoline3d saddle1/4#:width2#:style'long-dash)))

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

[ x-min
x-max
y-min
y-max
#:z-minz-min
#:z-maxz-max
#:samplessamples
#:levelslevels
#:colorscolors
#:widthswidths
#:stylesstyles
#:alphasalphas
#:labellabel])renderer3d?
f:(real? real? . -> .real? )
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
label:(or/c string? pict? #f)=#f
Returns a renderer that plots contour lines on the surface of a function.

The appearance keyword arguments are interpreted identically to the appearance keyword arguments to contours . In particular, when levels is 'auto, contour values correspond precisely to z axis ticks.

For example,
> (plot3d (contours3d (λ (xy)(+ (sqr x)(sqr y)))-1.11.1-1.11.1
#:label"z = x² + y²"))

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

[ x-min
x-max
y-min
y-max
#:z-minz-min
#:z-maxz-max
#:samplessamples
#:levelslevels
#:colorscolors
#:stylesstyles
#:line-colorsline-colors
#:line-widthsline-widths
#:line-stylesline-styles
#:contour-colorscontour-colors
#:contour-widthscontour-widths
#:contour-stylescontour-styles
#:alphasalphas
#:labellabel])
f:(real? real? . -> .real? )
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
contour-colors : (plot-colors/c (listof real? ))
= (contour-colors)
contour-widths : (pen-widths/c (listof real? ))
= (contour-widths)
contour-styles : (plot-pen-styles/c (listof real? ))
= (contour-styles)
label:(or/c string? pict? #f)=#f
Returns a renderer that plots contour intervals and contour lines on the surface of a function. The appearance keyword arguments are interpreted identically to the appearance keyword arguments to contour-intervals .

For example,
> (plot3d (contour-intervals3d (λ (xy)(+ (sqr x)(sqr y)))
-1.11.1-1.11.1
#:label"z = x² + y²"))

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

4.63D Isosurface RenderersπŸ”— i

procedure

d
[ x-min
x-max
y-min
y-max
z-min
z-max
#:samplessamples
#:colorcolor
#:stylestyle
#:line-colorline-color
#:line-widthline-width
#:line-styleline-style
#:alphaalpha
#:labellabel])renderer3d?
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
line-width:(>=/c 0)=(surface-line-width )
alpha:(real-in 01)=(surface-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that plots the surface of constant output value of the function f. The argument d is the constant value.

For example, a sphere is all the points in which the Euclidean distance function returns the sphere’s radius:
(λ (xyz)(sqrt (+ (sqr x)(sqr y)(sqr z))))1
-11-11-11)
#:altitude25)

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

[ x-min
x-max
y-min
y-max
z-min
z-max
#:d-mind-min
#:d-maxd-max
#:samplessamples
#:levelslevels
#:colorscolors
#:stylesstyles
#:line-colorsline-colors
#:line-widthsline-widths
#:line-stylesline-styles
#:alphasalphas
#:labellabel])renderer3d?
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
d-min:(or/c rational? #f)=#f
d-max:(or/c rational? #f)=#f
label:(or/c string? pict? #f)=#f
Returns a renderer that plots multiple isosurfaces. The appearance keyword arguments are interpreted similarly to those of contours .

Use this to visualize functions from three inputs to one output; for example:
> (define (saddlexyz)(- (sqr x)(* 1/2(+ (sqr y)(sqr z)))))
> (plot3d (isosurfaces3d saddle#:d-min-1#:d-max1#:label"")
#:x-min-2#:x-max2
#:y-min-2#:y-max2
#:z-min-2#:z-max2)

If it helps, think of the output of f as a density or charge.

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

4.73D Rectangle RenderersπŸ”— i

procedure

( rectangles3d rects
[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:colorcolor
#:stylestyle
#:line-colorline-color
#:line-widthline-width
#:line-styleline-style
#:alphaalpha
#:labellabel])renderer3d?
rects:(sequence/c (sequence/c #:min-count3ivl? ))
x-min:(or/c rational? #f)=#f
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=#f
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=#f
z-max:(or/c rational? #f)=#f
line-width:(>=/c 0)=(rectangle3d-line-width )
alpha:(real-in 01)=(rectangle-alpha )
label:(or/c string? pict? #f)=#f
Returns a renderer that draws rectangles.

This can be used to draw histograms; for example,
> (define (norm2xy)(exp (* -1/2(+ (sqr (- x5))(sqr y)))))
> (define x-ivls(bounds->intervals (linear-seq 2816)))
> (define y-ivls(bounds->intervals (linear-seq -5516)))
> (define x-mids(linear-seq 2815#:start?#f#:end?#f))
> (define y-mids(linear-seq -5515#:start?#f#:end?#f))
(for/list ([y-ivl(in-list y-ivls)]
[y(in-list y-mids)])
(for/list ([x-ivl(in-list x-ivls)]
[x(in-list x-mids)])
(define z(norm2xy))
(vector x-ivly-ivl(ivl 0z)))))
#:alpha3/4
#:label"Appx. 2D Normal"))

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:gapgap
#:colorcolor
#:stylestyle
#:line-colorline-color
#:line-widthline-width
#:line-styleline-style
#:alphaalpha
#:labellabel
#:add-x-ticks?add-x-ticks?
#:add-y-ticks?add-y-ticks?
#:x-far-ticks?x-far-ticks?
#:y-far-ticks?y-far-ticks?])
x-min:(or/c rational? #f)=0
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=0
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=0
z-max:(or/c rational? #f)=#f
line-width:(>=/c 0)=(rectangle3d-line-width )
alpha:(real-in 01)=(rectangle-alpha )
label:(or/c string? pict? #f)=#f
add-x-ticks?:boolean? =#t
add-y-ticks?:boolean? =#t
x-far-ticks?:boolean? =#f
y-far-ticks?:boolean? =#f
Returns a renderer that draws discrete histograms on a two-valued domain.

Missing pairs are not drawn; for example,
> (plot3d (discrete-histogram3d '(#(aa1)#(ab2)#(bb3))
#:label"Missing (b,a)"
#:color4#:line-color4))

Changed in version 7.9 of package plot-gui-lib: Added support for pictures for #:label

procedure

( stacked-histogram3d cat-vals
[ #:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:gapgap
#:colorscolors
#:stylesstyles
#:line-colorsline-colors
#:line-widthsline-widths
#:line-stylesline-styles
#:alphasalphas
#:labelslabels
#:add-x-ticks?add-x-ticks?
#:add-y-ticks?add-y-ticks?
#:x-far-ticks?x-far-ticks?
#:y-far-ticks?y-far-ticks?])
x-min:(or/c rational? #f)=0
x-max:(or/c rational? #f)=#f
y-min:(or/c rational? #f)=0
y-max:(or/c rational? #f)=#f
z-min:(or/c rational? #f)=0
z-max:(or/c rational? #f)=#f
labels:(labels/c nat/c )='(#f)
add-x-ticks?:boolean? =#t
add-y-ticks?:boolean? =#t
x-far-ticks?:boolean? =#f
y-far-ticks?:boolean? =#f
Returns a renderer that draws a stacked histogram. Think of it as a version of discrete-histogram that allows multiple values to be specified for each pair of categories.

Examples:
> (define data'(#(aa(111))#(ab(1.53))#(bb())#(ba(1/2))))
> (plot3d (stacked-histogram3d data#:labels'("Red"#f"Blue")
#:alphas'(2/312/3)))

procedure

[ label
#:colorcolor
#:sizesize
#:faceface
#:familyfamily
#:anchoranchor
#:angleangle
#:point-colorpoint-color
#:point-fill-colorpoint-fill-color
#:point-sizepoint-size
#:point-line-widthpoint-line-width
#:point-sympoint-sym
#:alphaalpha])
label:(or/c string? #f)=#f
size:(>=/c 0)=(plot-font-size )
angle:real? =(label-angle )
point-color:plot-color/c =(point-color)
point-fill-color:(or/c plot-color/c 'auto)='auto
point-size:(>=/c 0)=(label-point-size )
point-line-width:(>=/c 0)=(point-line-width)
point-sym:point-sym/c ='fullcircle
alpha:(real-in 01)=(label-alpha )
Returns a renderer that draws a labeled point. If label is #f, the point is labeled with its position. Analogous to point-label .

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /