If it seems porting will take too long, you can get your old code running more quickly using the Compatibility Module.
Plot now allows plot elements to request plot area bounds, and finds bounds large enough to fit all plot elements. The old default plot area bounds of [-5,5] × [-5,5] cannot be made consistent with the improved behavior; the default bounds are now "no bounds". This causes code such as (plot (line sin)), which does not state bounds, to fail.
The #:width and #:style keyword arguments to vector-field have been replaced by #:line-width and #:scale to be consistent with other functions.
The plot function no longer takes a (-> (is-a?/c 2d-view%) void?) as an argument, but a (treeof renderer2d?). The argument change in plot3d is similar. This should not affect most code because Plot encourages regarding these data types as black boxes.
The plot-extend module no longer exists.
The fit function and fit-result struct type have been removed.
You should also set (plot-deprecation-warnings? #t) to be alerted to uses of deprecated features.
Replace contour with contours, and replace shade with contour-intervals. These are mostly drop-in replacements: they should always work, but may not place contours at the same values (unless the levels are given as a list of values). For example, the default #:levels argument is now 'auto, which chooses contour values in the same way that z axis tick locations are usually chosen in 3D plots. The number of contour levels is therefore some number between 4 and 10, depending on the plot.
The safest way to ensure that plot can determine bounds for the plot area is to add #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 to every call to plot. Similarly, add #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 #:z-min -5 #:z-max 5 to every call to plot3d.
Because Plot is now smarter about choosing bounds, there are better ways. For example, suppose you have
You could either change it to
or change it to
When function is given x bounds, it determines tight y bounds.
Replace every #:width in a call to vector-field with #:line-width.
Replace every #:style 'scaled with #:scale 'auto (or because it is the default in both the old and new, take it out).
Replace every #:style 'real with #:scale 1.0.
Replace every #:style 'normalized with #:scale 'normalized.
> (parameterize ([plot-foreground '(0 0 128)] [plot-background '(224 224 224)]) (plot (function sin -5 5)))
10.4 Fixing Broken Calls to points
Chances are, if you used plot-extend, you no longer need it. The canonical plot-extend example used to be a version of line that drew dashed lines. Every line-drawing function in Plot now has a #:style or #:line-style keyword argument.
The rewritten Plot will eventually have a similar extension mechanism.
|(require plot)||package: plot-gui-lib|
The following functions exist for backward compatibility, but may be removed in the future. Set (plot-deprecation-warnings? #t) to be alerted the first time each is used.
(line f [ #:samples samples #:width width #:color color #:mode mode #:mapping mapping #:t-min t-min #:t-max t-max]) → renderer2d? f : (real? . -> . (or/c real? (vector/c real? real?))) 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
(contour f [ #:samples samples #:width width #:color color #:levels levels]) → renderer2d? f : (real? real? . -> . real?) samples : (and/c exact-integer? (>=/c 2)) = 50 width : (>=/c 0) = 1 color : plot-color/c = 'black
levels : (or/c (and/c exact-integer? (>=/c 2)) (listof real?)) = 10
(surface f [ #:samples samples #:width width #:color color]) → renderer3d? f : (real? real? . -> . real?) samples : (and/c exact-integer? (>=/c 2)) = 50 width : (>=/c 0) = 1 color : plot-color/c = 'black