On this page:
12.1Plotting
mix
8.18
top
up next →

12Compatibility ModuleπŸ”— i

Alexander Friedman,
Jamie Raymond,
and Neil Toronto

This module provides an interface compatible with Plot 5.1.3 and earlier.

Do not use this module in new programs. It is likely to disappear in a near future release.

Do not try to use both plot and plot/compat in the same program. The new features in Plot 5.2 and later require the objects plotted in plot have to be a different data type than the objects plotted in plot/compat. They do not coexist easily, and trying to make them do so will result in errors.

12.1PlottingπŸ”— i

procedure

( plot data
[ #:widthwidth
#:heightheight
#:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:x-labelx-label
#:y-labely-label
#:titletitle
#:fgcolorfgcolor
#:bgcolorbgcolor
#:lncolorlncolor
#:out-fileout-file])(is-a?/c image-snip% )
data:(-> (is-a?/c 2d-plot-area%)void? )
width:real? =400
height:real? =400
x-min:real? =-5
x-max:real? =5
y-min:real? =-5
y-max:real? =5
x-label:string? ="X axis"
y-label:string? ="Y axis"
title:string? =""
fgcolor:(list/c byte? byte? byte? )='(000)
bgcolor:(list/c byte? byte? byte? )='(255255255)
lncolor:(list/c byte? byte? byte? )='(25500)
out-file:(or/c path-string? output-port? #f)=#f
Plots data in 2D, where data is generated by functions like points or line .

A data value is represented as a procedure that takes a 2d-plot-area% instance and adds plot information to it.

The result is an image-snip% for the plot. If an #:out-file path or port is provided, the plot is also written as a PNG image to the given path or port.

The #:lncolor keyword argument is accepted for backward compatibility, but does nothing.

procedure

( plot3d data
[ #:widthwidth
#:heightheight
#:x-minx-min
#:x-maxx-max
#:y-miny-min
#:y-maxy-max
#:z-minz-min
#:z-maxz-max
#:altalt
#:azaz
#:x-labelx-label
#:y-labely-label
#:z-labelz-label
#:titletitle
#:fgcolorfgcolor
#:bgcolorbgcolor
#:lncolorlncolor
#:out-fileout-file])(is-a?/c image-snip% )
data:(-> (is-a?/c 3d-plot-area%)void? )
width:real? =400
height:real? =400
x-min:real? =-5
x-max:real? =5
y-min:real? =-5
y-max:real? =5
z-min:real? =-5
z-max:real? =5
alt:real? =30
az:real? =45
x-label:string? ="X axis"
y-label:string? ="Y axis"
z-label:string? ="Z axis"
title:string? =""
fgcolor:(list/c byte? byte? byte? )='(000)
bgcolor:(list/c byte? byte? byte? )='(255255255)
lncolor:(list/c byte? byte? byte? )='(25500)
out-file:(or/c path-string? output-port? #f)=#f
Plots data in 3D, where data is generated by a function like surface . The arguments alt and az set the viewing altitude (in degrees) and the azimuth (also in degrees), respectively.

A 3D data value is represented as a procedure that takes a 3d-plot-area% instance and adds plot information to it.

The #:lncolor keyword argument is accepted for backward compatibility, but does nothing.

procedure

( points vecs[#:symsym#:colorcolor])

(-> (is-a?/c 2d-plot-area%)void? )
vecs:(listof (vectorof real? ))
color:plot-color? ='black
Creates 2D plot data (to be provided to plot ) given a list of points specifying locations. The sym argument determines the appearance of the points. It can be a symbol, an ASCII character, or a small integer (between -1 and 127). The following symbols are known: 'pixel, 'dot, 'plus, 'asterisk, 'circle, 'times, 'square, 'triangle, 'oplus, 'odot, 'diamond, '5star, '6star, 'fullsquare, 'bullet, 'full5star, 'circle1, 'circle2, 'circle3, 'circle4, 'circle5, 'circle6, 'circle7, 'circle8, 'leftarrow, 'rightarrow, 'uparrow, 'downarrow.

procedure

( line f
[ #:samplessamples
#:widthwidth
#:colorcolor
#:modemode
#:mappingmapping
#:t-mint-min
#:t-maxt-max])(-> (is-a?/c 2d-plot-area%)void? )
samples:(and/c exact-integer? (>=/c 2))=150
width:(>=/c 0)=1
color:plot-color/c='red
mode:(one-of/c 'standard'parametric)='standard
mapping:(one-of/c 'cartesian'polar)='cartesian
t-min:real? =-5
t-max:real? =5
Creates 2D plot data to draw a line.

The line is specified in either functional, i.e. y = f(x), or parametric, i.e. x,y = f(t), mode. If the function is parametric, the mode argument must be set to 'parametric. The t-min and t-max arguments set the parameter when in parametric mode.

procedure

( error-bars vecs[#:colorcolor])

(-> (is-a?/c 2d-plot-area%)void? )
color:plot-color? ='black
Creates 2D plot data for error bars given a list of vectors. Each vector specifies the center of the error bar (x,y) as the first two elements and its magnitude as the third.

procedure

[ #:samplessamples
#:widthwidth
#:colorcolor
#:stylestyle])
(-> (is-a?/c 2d-plot-area%)void? )
samples:(and/c exact-integer? (>=/c 2))=20
color:plot-color? ='red
style:(one-of/c 'scaled'normalized'real)='scaled
Creates 2D plot data to draw a vector-field from a vector-valued function.

procedure

( contour f
[ #:samplessamples
#:widthwidth
#:colorcolor
#:levelslevels])
(-> (is-a?/c 2d-plot-area%)void? )
width:(>=/c 0)=1
color:plot-color/c='black
= 10
Creates 2D plot data to draw contour lines, rendering a 3D function a 2D graph cotours (respectively) to represent the value of the function at that position.

procedure

( shade f[#:samplessamples#:levelslevels])

(-> (is-a?/c 2d-plot-area%)void? )
samples:(and/c exact-integer? (>=/c 2))=50
= 10
Creates 2D plot data to draw like contour , except using shading instead of contour lines.

procedure

( surface f
[ #:samplessamples
#:widthwidth
#:colorcolor])
(-> (is-a?/c 3d-plot-area%)void? )
samples:(and/c exact-integer? (>=/c 2))=50
width:(>=/c 0)=1
color:plot-color/c='black
Creates 3D plot data to draw a 3D surface in a 2D box, showing only the top of the surface.

procedure

( mix data...)(-> any/c void? )

data:(-> any/c void? )
Creates a procedure that calls each data on its argument in order. Thus, this function can composes multiple plot datas into a single data.

procedure

( plot-color? v)boolean?

v:any/c
Returns #t if v is one of the following symbols, #f otherwise:

'white'black'yellow'green'aqua'pink
'wheat'grey'blown'blue'violet'cyan
'turquoise'magenta'salmon'red

12.2Miscellaneous FunctionsπŸ”— i

procedure

( derivative f[h])(-> real? real? )

f:(-> real? real? )
h:real? =1e-6
Creates a function that evaluates the numeric derivative of f. The given h is the divisor used in the calculation.

procedure

( gradient f[h])

h:real? =1e-6
Creates a vector-valued function that computes the numeric gradient of f.

procedure

( make-vec fxfy)

Creates a vector-valued function from two parts.

top
up next →

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