<div dir="ltr">Oh, I finally understand.<div><br></div><div>Yes, I agree that this is a good change.</div><div><br></div><div>Sorry for the confusion.</div><div><br></div><div>Robby</div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Apr 4, 2014 at 10:04 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">
Yes, the relative size of the font will grow, as well as minor things, such as that the lines will thicken a bit. IOW, without the fix, if you output the same plot to a PDF, SVG, and PNG, the PDF will have a smaller font and thinner lines than the SVG and PNG.<br>
<br>
It can be hard to tell without converting them to the same format for comparison, which is why I didn't spot this for so long. I just thought papers looked better when plots had slightly larger fonts.<br>
<br>
I verified that the fix works by using the Gimp to convert a PDF and an SVG to two 500x500 images, and pasted one over the other.<br>
<br>
Neil ⊥<div class=""><br>
<br>
On 04/04/2014 06:42 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="">
I'm not completely clear on the precise impact of old papers: will the<br>
plot itself stay the same size, but the relative size of the font (to<br>
the other plot elements) inside the plot change only? Or something else?<br>
<br>
Robby<br>
<br>
<br>
On Fri, Apr 4, 2014 at 12:08 AM, Neil Toronto <<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><br></div><div class="">
<mailto:<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><u></u>>> wrote:<br>
<br>
I did it because I was tired of putting (plot-font-size 15) at the<br>
top of every program that produced a plot for a paper. Also, I think<br>
it was bad for the "preview" in DrRacket to look different from the<br>
PDFs. (Some of my plots in DrRacket had legends that badly<br>
overlapped the data in order to look right in PDF format.) It will<br>
cause existing PDF plots to have larger text, which could look wrong<br>
in plots that use the font size workaround. But I think it's the<br>
right move in the long run.<br>
<br>
Here's one thing I could do: document `plot-ps-setup' and export an<br>
`old-plot-ps-setup' that's the default instance of `ps-setup%', so<br>
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 ⊥<br>
<br>
<br>
On 04/03/2014 10:37 AM, Robby Findler wrote:<br>
<br>
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>
<mailto:<a href="mailto:ntoronto@racket-lang.org" target="_blank">ntoronto@racket-lang.<u></u>org</a>><br></div>
<mailto:<a href="mailto:ntoronto@racket-lang." target="_blank">ntoronto@racket-lang.</a>_<u></u>_org<div class=""><br>
<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></div>
<a href="http://git.racket-lang.org/__plt/87cfce97f9..efc46ded6d" target="_blank">http://git.racket-lang.org/__<u></u>plt/87cfce97f9..efc46ded6d</a><div class=""><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<br></div>
]=============================<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/<div class=""><br>
<br>
~~~~~~~~~~<br>
<br>
c1550b6 Neil Toronto <<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><br>
<mailto:<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><u></u>><br></div>
<mailto:<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><br>
<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>
:<br>
| Remove unnecessary use of `remove-duplicates'<br>
:<br></div>
M .../plot-lib/plot/private/__<u></u>plot3d/bsp.rkt |<br>
11 +--<br>
M .../plot-test/plot/tests/__<u></u>plot3d-bsp-tests.rkt | 91<div class=""><br>
++++++++------------<br>
<br>
~~~~~~~~~~<br>
<br>
efc46de Neil Toronto <<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><br>
<mailto:<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><u></u>><br></div>
<mailto:<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><br>
<mailto:<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><u></u>>__>> 2014-04-02 23:16<div class=""><br>
<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<br>
differences)<br>
| regardless of file format. Scaling and other PS options<br>
are controlled<br>
| by a `plot-ps-setup' parameter. Not sure how useful that<br>
is, yet, so<br>
| it's undocumented.<br>
:<br>
M<br></div>
pkgs/plot-pkgs/plot-lib/plot/_<u></u>_private/no-gui/plot2d.rkt | 14<br>
++++++++------<br>
M<br>
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<br>
| 9<br>
++++++++-<br>
M .../plot-lib/plot/private/__<u></u>contracted/parameters.rkt<div class=""><br>
| 2 +-<br>
<br>
=====[ Overall Diff<br></div>
]=============================<u></u>__======================<br>
<br>
pkgs/plot-pkgs/plot-lib/plot/_<u></u>_private/common/parameters.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>__~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
---<br>
OLD/pkgs/plot-pkgs/plot-lib/__<u></u>plot/private/common/__<u></u>parameters.rkt<br>
+++<br>
NEW/pkgs/plot-pkgs/plot-lib/__<u></u>plot/private/common/__<u></u>parameters.rkt<div class=""><br>
@@ -3,6 +3,7 @@<br>
;; Parameters that control the look and behavior of plots.<br>
<br>
(require racket/contract unstable/parameter-group<br></div>
unstable/latent-contract/__<u></u>defthing<div class=""><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%)<br>
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>
<br></div>
pkgs/plot-pkgs/plot-lib/plot/_<u></u>_private/contracted/<u></u>parameters.__rkt<br>
<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>__~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>~~__~~<br>
---<br>
OLD/pkgs/plot-pkgs/plot-lib/__<u></u>plot/private/contracted/__<u></u>parameters.rkt<br>
+++<br>
NEW/pkgs/plot-pkgs/plot-lib/__<u></u>plot/private/contracted/__<u></u>parameters.rkt<div class=""><br>
@@ -28,7 +28,7 @@<br>
plot3d-samples<br>
plot3d-angle plot3d-altitude<br>
plot3d-ambient-light plot3d-diffuse-light?<br>
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></div>
pkgs/plot-pkgs/plot-lib/plot/_<u></u>_private/no-gui/plot2d.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>__~~~~~~~~~~~~~~~~~~~~~~~~<br>
---<br>
OLD/pkgs/plot-pkgs/plot-lib/__<u></u>plot/private/no-gui/plot2d.rkt<br>
+++<br>
NEW/pkgs/plot-pkgs/plot-lib/__<u></u>plot/private/no-gui/plot2d.rkt<div><div class="h5"><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]<br>
[output output])]<br>
+ [(ps) (parameterize ([current-ps-setup<br>
(plot-ps-setup)])<br>
+ (new post-script-dc%<br>
+ [interactive<br>
(plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
+ [as-eps #t] [width width] [height<br>
height]<br>
[output output]))]<br>
+ [(pdf) (parameterize ([current-ps-setup<br>
(plot-ps-setup)])<br>
+ (new pdf-dc%<br>
+ [interactive<br>
(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<br>
get-device-scale))<br>
<br></div></div>
pkgs/plot-pkgs/plot-lib/plot/_<u></u>_private/no-gui/plot3d.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>__~~~~~~~~~~~~~~~~~~~~~~~~<br>
---<br>
OLD/pkgs/plot-pkgs/plot-lib/__<u></u>plot/private/no-gui/plot3d.rkt<br>
+++<br>
NEW/pkgs/plot-pkgs/plot-lib/__<u></u>plot/private/no-gui/plot3d.rkt<div><div class="h5"><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]<br>
[output output])]<br>
+ [(ps) (parameterize ([current-ps-setup<br>
(plot-ps-setup)])<br>
+ (new post-script-dc%<br>
+ [interactive<br>
(plot-ps/pdf-interactive?)]<br>
[parent #f] [use-paper-bbox #f]<br>
+ [as-eps #t] [width width] [height<br>
height]<br>
[output output]))]<br>
+ [(pdf) (parameterize ([current-ps-setup<br>
(plot-ps-setup)])<br>
+ (new pdf-dc%<br>
+ [interactive<br>
(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<br>
get-device-scale))<br>
<br></div></div>
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<div><div class="h5"><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<br>
(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></div></div>
pkgs/plot-pkgs/plot-test/plot/<u></u>__tests/plot3d-bsp-tests.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>__~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
---<br>
OLD/pkgs/plot-pkgs/plot-test/_<u></u>_plot/tests/plot3d-bsp-tests._<u></u>_rkt<br>
+++<br>
NEW/pkgs/plot-pkgs/plot-test/_<u></u>_plot/tests/plot3d-bsp-tests._<u></u>_rkt<div><div class="h5"><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<br>
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>
<br>
<br>
</div></div></blockquote>
<br>
</blockquote></div><br></div>