<div dir="ltr">I'm not completely clear on the precise impact of old papers: will the plot itself stay the same size, but the relative size of the font (to the other plot elements) inside the plot change only? Or something else?<div>
<br></div><div>Robby</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 4, 2014 at 12:08 AM, Neil Toronto <span dir="ltr"><<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I did it because I was tired of putting (plot-font-size 15) at the top of every program that produced a plot for a paper. Also, I think it was bad for the "preview" in DrRacket to look different from the PDFs. (Some of my plots in DrRacket had legends that badly overlapped the data in order to look right in PDF format.) It will cause existing PDF plots to have larger text, which could look wrong in plots that use the font size workaround. But I think it's the right move in the long run.<br>
<br>
Here's one thing I could do: document `plot-ps-setup' and export an `old-plot-ps-setup' that's the default instance of `ps-setup%', so programs that produce plots for papers could start this way:<br>
<br>
#lang racket<br>
(require plot)<br>
(plot-ps-setup old-plot-ps-setup)<br>
<br>
Maybe that parameter is useful after all.<br>
<br>
Neil ⊥<div class=""><br>
<br>
On 04/03/2014 10:37 AM, Robby Findler wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
Is efc46de backwards compatible? (I worry about breaking people's<br>
papers, specifically.)<br>
<br>
Robby<br>
<br>
<br>
On Thu, Apr 3, 2014 at 12:20 AM, <<a href="mailto:ntoronto@racket-lang.org" target="_blank">ntoronto@racket-lang.org</a><br></div><div class="">
<mailto:<a href="mailto:ntoronto@racket-lang.org" target="_blank">ntoronto@racket-lang.<u></u>org</a>>> wrote:<br>
<br>
ntoronto has updated `master' from 87cfce97f9 to efc46ded6d.<br>
<a href="http://git.racket-lang.org/plt/87cfce97f9..efc46ded6d" target="_blank">http://git.racket-lang.org/<u></u>plt/87cfce97f9..efc46ded6d</a><br>
<br>
=====[ 2 Commits ]=============================<u></u>=========================<br>
Directory summary:<br>
8.2% pkgs/plot-pkgs/plot-lib/plot/<u></u>private/common/<br>
35.5% pkgs/plot-pkgs/plot-lib/plot/<u></u>private/no-gui/<br>
12.4% pkgs/plot-pkgs/plot-lib/plot/<u></u>private/plot3d/<br>
41.2% pkgs/plot-pkgs/plot-test/plot/<u></u>tests/<br>
<br>
~~~~~~~~~~<br>
<br>
c1550b6 Neil Toronto <<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><br></div>
<mailto:<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><u></u>>> 2014-04-02 22:06<div class=""><br>
:<br>
| Remove unnecessary use of `remove-duplicates'<br>
:<br>
M .../plot-lib/plot/private/<u></u>plot3d/bsp.rkt | 11 +--<br>
M .../plot-test/plot/tests/<u></u>plot3d-bsp-tests.rkt | 91<br>
++++++++------------<br>
<br>
~~~~~~~~~~<br>
<br>
efc46de Neil Toronto <<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><br></div>
<mailto:<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><u></u>>> 2014-04-02 23:16<div><div class="h5"><br>
:<br>
| Changed PDF/PS backend to use 1.0 x 1.0 scaling<br>
|<br>
| This makes plotting to a file the same (well, with slight differences)<br>
| regardless of file format. Scaling and other PS options are controlled<br>
| by a `plot-ps-setup' parameter. Not sure how useful that is, yet, so<br>
| it's undocumented.<br>
:<br>
M pkgs/plot-pkgs/plot-lib/plot/<u></u>private/no-gui/plot2d.rkt | 14<br>
++++++++------<br>
M pkgs/plot-pkgs/plot-lib/plot/<u></u>private/no-gui/plot3d.rkt | 14<br>
++++++++------<br>
M .../plot-lib/plot/private/<u></u>common/parameters.rkt | 9<br>
++++++++-<br>
M .../plot-lib/plot/private/<u></u>contracted/parameters.rkt | 2 +-<br>
<br>
=====[ Overall Diff ]=============================<u></u>======================<br>
<br>
pkgs/plot-pkgs/plot-lib/plot/<u></u>private/common/parameters.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/common/<u></u>parameters.rkt<br>
+++ NEW/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/common/<u></u>parameters.rkt<br>
@@ -3,6 +3,7 @@<br>
;; Parameters that control the look and behavior of plots.<br>
<br>
(require racket/contract unstable/parameter-group<br>
unstable/latent-contract/<u></u>defthing<br>
+ racket/class racket/draw<br>
"contract.rkt"<br>
"draw.rkt"<br>
"axis-transform.rkt"<br>
@@ -107,11 +108,17 @@<br>
<br>
;; Output<br>
<br>
+(define default-plot-ps-setup (new ps-setup%))<br>
+(send default-plot-ps-setup set-margin 0 0)<br>
+(send default-plot-ps-setup set-scaling 1 1)<br>
+<br>
(defparam plot-new-window? boolean? #f)<br>
(defparam plot-jpeg-quality (integer-in 0 100) 100)<br>
(defparam plot-ps/pdf-interactive? boolean? #f)<br>
+(defparam plot-ps-setup (is-a?/c ps-setup%) default-plot-ps-setup)<br>
<br>
-(define-parameter-group plot-output (plot-new-window?<br>
plot-jpeg-quality plot-ps/pdf-interactive?))<br>
+(define-parameter-group plot-output<br>
+ (plot-new-window? plot-jpeg-quality plot-ps/pdf-interactive?<br>
plot-ps-setup))<br>
<br>
;; Labels<br>
<br>
<br>
pkgs/plot-pkgs/plot-lib/plot/<u></u>private/contracted/parameters.<u></u>rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>~~<br>
--- OLD/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/contracted/<u></u>parameters.rkt<br>
+++ NEW/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/contracted/<u></u>parameters.rkt<br>
@@ -28,7 +28,7 @@<br>
plot3d-samples<br>
plot3d-angle plot3d-altitude<br>
plot3d-ambient-light plot3d-diffuse-light? plot3d-specular-light?<br>
- plot-new-window? plot-jpeg-quality plot-ps/pdf-interactive?<br>
+ plot-new-window? plot-jpeg-quality plot-ps/pdf-interactive?<br>
plot-ps-setup<br>
plot-title<br>
plot-x-label plot-y-label plot-z-label<br>
plot-x-far-label plot-y-far-label plot-z-far-label<br>
<br>
pkgs/plot-pkgs/plot-lib/plot/<u></u>private/no-gui/plot2d.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>~~~~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/no-gui/plot2d.rkt<br>
+++ NEW/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/no-gui/plot2d.rkt<br>
@@ -112,12 +112,14 @@<br>
[(ps pdf svg)<br>
(define dc<br>
(case real-kind<br>
- [(ps) (new post-script-dc%<br>
- [interactive (plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
- [as-eps #t] [width width] [height height]<br>
[output output])]<br>
- [(pdf) (new pdf-dc%<br>
- [interactive (plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
- [width width] [height height] [output output])]<br>
+ [(ps) (parameterize ([current-ps-setup (plot-ps-setup)])<br>
+ (new post-script-dc%<br>
+ [interactive (plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
+ [as-eps #t] [width width] [height height]<br>
[output output]))]<br>
+ [(pdf) (parameterize ([current-ps-setup (plot-ps-setup)])<br>
+ (new pdf-dc%<br>
+ [interactive (plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
+ [width width] [height height] [output<br>
output]))]<br>
[(svg) (new svg-dc%<br>
[width width] [height height] [output<br>
output] [exists 'truncate/replace])]))<br>
(define-values (x-scale y-scale) (send dc get-device-scale))<br>
<br>
pkgs/plot-pkgs/plot-lib/plot/<u></u>private/no-gui/plot3d.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>~~~~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/no-gui/plot3d.rkt<br>
+++ NEW/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/no-gui/plot3d.rkt<br>
@@ -129,12 +129,14 @@<br>
[(ps pdf svg)<br>
(define dc<br>
(case real-kind<br>
- [(ps) (new post-script-dc%<br>
- [interactive (plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
- [as-eps #t] [width width] [height height]<br>
[output output])]<br>
- [(pdf) (new pdf-dc%<br>
- [interactive (plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
- [width width] [height height] [output output])]<br>
+ [(ps) (parameterize ([current-ps-setup (plot-ps-setup)])<br>
+ (new post-script-dc%<br>
+ [interactive (plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
+ [as-eps #t] [width width] [height height]<br>
[output output]))]<br>
+ [(pdf) (parameterize ([current-ps-setup (plot-ps-setup)])<br>
+ (new pdf-dc%<br>
+ [interactive (plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
+ [width width] [height height] [output<br>
output]))]<br>
[(svg) (new svg-dc%<br>
[width width] [height height] [output<br>
output] [exists 'truncate/replace])]))<br>
(define-values (x-scale y-scale) (send dc get-device-scale))<br>
<br>
pkgs/plot-pkgs/plot-lib/plot/<u></u>private/plot3d/bsp.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/plot3d/bsp.rkt<br>
+++ NEW/pkgs/plot-pkgs/plot-lib/<u></u>plot/private/plot3d/bsp.rkt<br>
@@ -499,8 +499,7 @@<br>
(cond<br>
[(empty? ps) #f]<br>
[else<br>
- (define vs (remove-duplicates (bsp-polys->vertices ps)))<br>
- (define axes (vertices->axes vs))<br>
+ (define axes (vertices->axes (bsp-polys->vertices ps)))<br>
(define center (list->flvector (map axis-mid axes)))<br>
<br>
;; Planes defined by neighboring polygon vertices<br>
@@ -530,8 +529,7 @@<br>
(cond<br>
[(empty? ls) #f]<br>
[else<br>
- (define vs (remove-duplicates (bsp-lines->vertices ls)))<br>
- (define axes (vertices->axes vs))<br>
+ (define axes (vertices->axes (bsp-lines->vertices ls)))<br>
(define center (list->flvector (map axis-mid axes)))<br>
<br>
;; Planes defined by line segments and basis vectors (i.e.<br>
one basis in normal is zero)<br>
@@ -560,9 +558,8 @@<br>
(cond<br>
[(and (empty? ls) (empty? ps)) #f]<br>
[else<br>
- (define vs (remove-duplicates (append (append* (map<br>
lines-vertices ls))<br>
- (append* (map<br>
points-vertices ps)))))<br>
- (define axes (vertices->axes vs))<br>
+ (define axes (vertices->axes (append (append* (map<br>
lines-vertices ls))<br>
+ (append* (map<br>
points-vertices ps)))))<br>
(define center (list->flvector (map axis-mid axes)))<br>
<br>
(: try-nondisjoint-split (-> (U #f BSP-Tree)))<br>
<br>
pkgs/plot-pkgs/plot-test/plot/<u></u>tests/plot3d-bsp-tests.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/pkgs/plot-pkgs/plot-test/<u></u>plot/tests/plot3d-bsp-tests.<u></u>rkt<br>
+++ NEW/pkgs/plot-pkgs/plot-test/<u></u>plot/tests/plot3d-bsp-tests.<u></u>rkt<br>
@@ -1,23 +1,5 @@<br>
#lang racket<br>
<br>
-#|<br>
-TODO<br>
-<br>
-BSP<br>
- - deal better with polygon + many non-polygon shapes<br>
- - avoid more recomputation in build-bsp3d (i.e. precompute<br>
bounding and central planes)<br>
- - make middle shapes in bsp-node a BSP-Tree<br>
- - speed up disjoint splitting<br>
-<br>
-insert line segments into BSP as polygonal clipping regions?<br>
-<br>
-slow parts<br>
- - 22.3: build-bsp-tree<br>
- - 15.6: contour renderer proc<br>
- - 12.7: clip-polygon<br>
- - 6.0: bin-shapes<br>
-|#<br>
-<br>
(require plot<br>
(except-in plot/utils sum flsum sample)<br>
math<br>
@@ -95,41 +77,42 @@ slow parts<br>
(points3d xyzs #:sym 'dot)))))<br>
<br>
(time<br>
- (plot3d<br>
- (list (contour-intervals3d<br>
- (λ (x y)<br>
- (* x (+ 0.1 y)))<br>
- -1 1 -1 1<br>
- #:samples 41<br>
- #:alphas '(0.85)<br>
- ;#:alpha 0.75<br>
- ;#:line-width 2<br>
- ;#:line-widths '(2)<br>
- ;#:line-styles '(transparent)<br>
- #:contour-widths '(2)<br>
- ;#:color 1<br>
- ;#:label ""<br>
- )<br>
-<br>
- (surface3d<br>
- (λ (x y)<br>
- (* (- (* (flnormal-pdf 0.0 0.2 (fl x) #f)<br>
- (flnormal-pdf 0.0 0.2 (fl y) #f))<br>
- 0.7)<br>
- 0.4))<br>
- -1 1 -1 1<br>
- #:samples 40<br>
- ;#:alphas '(0.75)<br>
- #:alpha 0.95<br>
- #:color "plum"<br>
- #:line-color 6<br>
- ;#:line-style 'transparent<br>
- ;#:line-width 2<br>
- ))<br>
- #:x-min -1 #:x-max 1<br>
- #:y-min -1 #:y-max 1<br>
- ;#:out-file "test.pdf"<br>
- ))<br>
+ (for/last ([_ (in-range 1)])<br>
+ (plot3d<br>
+ (list (contour-intervals3d<br>
+ (λ (x y)<br>
+ (* x (+ 0.1 y)))<br>
+ -1 1 -1 1<br>
+ #:samples 41<br>
+ #:alphas '(0.85)<br>
+ ;#:alpha 0.75<br>
+ ;#:line-width 2<br>
+ ;#:line-widths '(2)<br>
+ ;#:line-styles '(transparent)<br>
+ #:contour-widths '(2)<br>
+ ;#:color 1<br>
+ ;#:label ""<br>
+ )<br>
+<br>
+ (surface3d<br>
+ (λ (x y)<br>
+ (* (- (* (flnormal-pdf 0.0 0.2 (fl x) #f)<br>
+ (flnormal-pdf 0.0 0.2 (fl y) #f))<br>
+ 0.7)<br>
+ 0.4))<br>
+ -1 1 -1 1<br>
+ #:samples 40<br>
+ ;#:alphas '(0.75)<br>
+ #:alpha 0.95<br>
+ #:color "plum"<br>
+ #:line-color 6<br>
+ ;#:line-style 'transparent<br>
+ ;#:line-width 2<br>
+ ))<br>
+ #:x-min -1 #:x-max 1<br>
+ #:y-min -1 #:y-max 1<br>
+ ;#:out-file "test.pdf"<br>
+ )))<br>
<br>
(plot3d (list (surface3d * -1 1 -1 1 #:samples 6 #:alpha 0.75<br>
#:color 1)<br>
(surface3d (λ (x y) (+ 0.1 (* x y))) -1 1 -1 1<br>
#:samples 6 #:alpha 0.75 #:color 2)<br>
@@ -140,7 +123,7 @@ slow parts<br>
(plot3d (list<br>
(isosurface3d (λ (x y z) (+ (- 1 x) (- 1 y) (- z 1.5))) 0<br>
#:alpha 0.85 #:color 2 #:line-color 2<br>
- #:samples 2)<br>
+ #:samples 4)<br>
(discrete-histogram3d (list (vector 'a 'a 1)<br>
(vector 'a 'b 2)<br>
(vector 'b 'b 3))<br>
<br>
<br>
</div></div></blockquote>
<br>
</blockquote></div><br></div>