diff --git a/collects/plot/common/vector.rkt b/collects/plot/common/vector.rkt index 050aa3e2c6..a434b0dca2 100644 --- a/collects/plot/common/vector.rkt +++ b/collects/plot/common/vector.rkt @@ -7,9 +7,6 @@ (provide (all-defined-out)) -(define (vector-take-2 v) (vector-take v 2)) -(define (vector-take-3 v) (vector-take v 3)) - (define (vcross v1 v2) (match-define (vector x1 y1 z1) v1) (match-define (vector x2 y2 z2) v2) diff --git a/collects/plot/compat.rkt b/collects/plot/compat.rkt index c88642489b..f37ba58755 100644 --- a/collects/plot/compat.rkt +++ b/collects/plot/compat.rkt @@ -2,7 +2,7 @@ ;; A compatibility module for the old 'plot'. -(require racket/contract racket/class racket/snip racket/draw +(require racket/contract racket/class racket/snip racket/draw racket/vector ;; Plotting "common/contract.rkt" "common/contract-doc.rkt" @@ -144,7 +144,8 @@ [#:sym sym (or/c char? string? integer? symbol?) 'square] [#:color color plot-color? 'black] ) ((is-a?/c 2d-plot-area%) . -> . void?) - (renderer2d->plot-data (new.points vecs #:sym sym #:size 6 #:color color))) + (renderer2d->plot-data (new.points (map (λ (v) (vector-take v 2)) vecs) + #:sym sym #:size 6 #:color color))) (defproc (vector-field [f ((vector/c real? real?) . -> . (vector/c real? real?))] [#:samples samples (integer>=/c 2) 20] diff --git a/collects/plot/plot2d/contour.rkt b/collects/plot/plot2d/contour.rkt index afa1be3c68..05bd701f7a 100644 --- a/collects/plot/plot2d/contour.rkt +++ b/collects/plot/plot2d/contour.rkt @@ -2,7 +2,7 @@ ;; Renderers for contour lines and contour intervals -(require racket/contract racket/class racket/match racket/list racket/flonum +(require racket/contract racket/class racket/match racket/list racket/flonum racket/vector "../common/math.rkt" "../common/draw.rkt" "../common/marching-squares.rkt" @@ -135,7 +135,8 @@ (exact->inexact z3) (exact->inexact z4)))]) (cond [(equal? poly 'full) (list (vector xa ya) (vector xa yb) (vector xb yb) (vector xb ya))] - [else (map vector-take-2 (scale-normalized-poly poly xa xb ya yb))]))))) + [else (map (λ (v) (vector-take v 2)) + (scale-normalized-poly poly xa xb ya yb))]))))) (define (draw-polys) (for ([poly (in-list polys)]) diff --git a/collects/plot/plot2d/point.rkt b/collects/plot/plot2d/point.rkt index de46847770..64f5e30cf0 100644 --- a/collects/plot/plot2d/point.rkt +++ b/collects/plot/plot2d/point.rkt @@ -25,7 +25,7 @@ (if label (point-legend-entry label sym color size line-width) empty)) -(defproc (points [vs (listof (vectorof real?))] +(defproc (points [vs (listof (vector/c real? real?))] [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] [#:sym sym point-sym/c (point-sym)] @@ -35,7 +35,7 @@ [#:alpha alpha (real-in 0 1) (point-alpha)] [#:label label (or/c string? #f) #f] ) renderer2d? - (let ([vs (filter vregular? (map vector-take-2 vs))]) + (let ([vs (filter vregular? vs)]) (cond [(empty? vs) null-renderer2d] [else (match-define (list (vector xs ys) ...) vs) diff --git a/collects/plot/plot3d/point.rkt b/collects/plot/plot3d/point.rkt index 73bb7bfd71..d5652554bd 100644 --- a/collects/plot/plot3d/point.rkt +++ b/collects/plot/plot3d/point.rkt @@ -32,7 +32,7 @@ [#:alpha alpha (real-in 0 1) (point-alpha)] [#:label label (or/c string? #f) #f] ) renderer3d? - (let ([vs (filter vregular? (map vector-take-3 vs))]) + (let ([vs (filter vregular? vs)]) (cond [(empty? vs) null-renderer3d] [else (match-define (list (vector xs ys zs) ...) vs) diff --git a/collects/plot/scribblings/plot.scrbl b/collects/plot/scribblings/plot.scrbl index 4fc4772c11..cf6faa6a15 100644 --- a/collects/plot/scribblings/plot.scrbl +++ b/collects/plot/scribblings/plot.scrbl @@ -9,7 +9,7 @@ @defmodule[plot] -@(plot-name) provides an flexible interface for producing nearly any kind of plot. +@(plot-name) provides a flexible interface for producing nearly any kind of plot. It includes many common kinds already, such as scatter plots, line plots, contour plots, histograms, and 3D surfaces and isosurfaces. Thanks to Racket's excellent multiple-backend drawing library, @(plot-name) can render plots as manipulatable images in DrRacket, as bitmaps in slideshows, as PNG, PDF, PS and SVG files, or on any device context. diff --git a/collects/plot/tests/fit-test-2.rkt b/collects/plot/tests/fit-test-2.rkt index e12cea0e9c..fd8b256223 100644 --- a/collects/plot/tests/fit-test-2.rkt +++ b/collects/plot/tests/fit-test-2.rkt @@ -446,7 +446,7 @@ 255 255 -1 -1 43 1 #"\0" 0 -1 1 #"\0" 1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 1 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255 -255 255 -1 -1 0 747 0 26 3 12 #"#lang racket" +255 255 -1 -1 0 748 0 26 3 12 #"#lang racket" 0 0 4 29 1 #"\n" 0 0 4 29 1 #"\n" 0 0 17 3 81 @@ -1245,7 +1245,15 @@ 0 0 22 3 1 #"(" 0 0 14 3 6 #"points" 0 0 4 3 1 #" " -0 0 14 3 17 #"experimental-data" +0 0 22 3 1 #"(" +0 0 14 3 3 #"map" +0 0 4 3 1 #" " +0 0 14 3 6 #"vector" +0 0 4 3 1 #" " +0 0 14 3 5 #"times" +0 0 4 3 1 #" " +0 0 14 3 4 #"vals" +0 0 22 3 1 #")" 0 0 4 3 1 #" " 0 0 22 3 5 #"#:sym" 0 0 4 3 1 #" " @@ -1409,8 +1417,7 @@ 0 0 19 3 1 #"\"" 0 0 19 3 3 #"The" 0 0 19 3 1 #" " -0 0 19 3 3 #"old" -0 0 19 3 29 #" library produced this plot:\"" +0 0 19 3 32 #"old library produced this plot:\"" 0 0 22 3 1 #")" 0 0 4 29 1 #"\n" 0 2 83 4 1 #"\0" @@ -2587,8 +2594,7 @@ 0 0 17 3 1 #"a" 0 0 17 3 1 #" " 0 0 17 3 4 #"44.5" -0 0 17 3 1 #" " -0 0 17 3 4 #"0.5)" +0 0 17 3 5 #" 0.5)" 0 0 4 29 1 #"\n" 0 0 17 3 2 #";(" 0 0 17 3 7 #"check-=" @@ -2596,8 +2602,7 @@ 0 0 17 3 3 #"tau" 0 0 17 3 1 #" " 0 0 17 3 4 #"57.5" -0 0 17 3 1 #" " -0 0 17 3 4 #"0.5)" +0 0 17 3 5 #" 0.5)" 0 0 4 29 1 #"\n" 0 0 17 3 2 #";(" 0 0 17 3 7 #"check-=" @@ -2605,8 +2610,7 @@ 0 0 17 3 3 #"phi" 0 0 17 3 1 #" " 0 0 17 3 5 #"-0.38" -0 0 17 3 1 #" " -0 0 17 3 5 #"0.05)" +0 0 17 3 6 #" 0.05)" 0 0 4 29 1 #"\n" 0 0 17 3 2 #";(" 0 0 17 3 7 #"check-=" @@ -2614,16 +2618,13 @@ 0 0 17 3 1 #"T" 0 0 17 3 1 #" " 0 0 17 3 4 #"13.1" -0 0 17 3 1 #" " -0 0 17 3 4 #"0.5)" +0 0 17 3 5 #" 0.5)" 0 0 4 29 1 #"\n" 0 0 17 3 2 #";(" 0 0 17 3 7 #"check-=" 0 0 17 3 1 #" " 0 0 17 3 6 #"theta0" 0 0 17 3 1 #" " -0 0 17 3 3 #"2.5" -0 0 17 3 1 #" " -0 0 17 3 4 #"0.5)" +0 0 17 3 8 #"2.5 0.5)" 0 0 4 29 1 #"\n" 0 0 diff --git a/collects/plot/tests/plot2d-tests.rkt b/collects/plot/tests/plot2d-tests.rkt index 6e6e7046e1..3df298fdf3 100644 --- a/collects/plot/tests/plot2d-tests.rkt +++ b/collects/plot/tests/plot2d-tests.rkt @@ -11,7 +11,6 @@ (plot empty #:x-min -1 #:x-max 1 #:y-min -1 #:y-max 1) -#; (parameterize ([plot-x-transform (hand-drawn-transform 200)] [plot-y-transform (hand-drawn-transform 200)]) (plot (function sqr -1 1)))