summaryrefslogtreecommitdiffstats
path: root/grapheps.ps
diff options
context:
space:
mode:
Diffstat (limited to 'grapheps.ps')
-rw-r--r--grapheps.ps36
1 files changed, 23 insertions, 13 deletions
diff --git a/grapheps.ps b/grapheps.ps
index 87658dd..95f200e 100644
--- a/grapheps.ps
+++ b/grapheps.ps
@@ -1,7 +1,9 @@
-%%EndComments
/plotdict 100 dict def
plotdict begin
+% Get dimensions the preamble left on the stack.
+4 array astore /whole-page exch def
+
% Definitions so that internal assignments are bound before setting.
/DATA 0 def
/DEN 0 def
@@ -68,8 +70,11 @@ plotdict begin
{lineto}
{currentpoint pop topedge lineto closepath fill}] bind def
% Render lines from x-axis to points
-/impulse [{} {moveto currentpoint pop 0 lineto} {}] bind def
-/bargraph [{} {exch GR sub exch 0 exch GD exch rectstroke} {}] bind def
+/impulse [{} {moveto XRNG 0 get 0 gtrans exch pop
+ currentpoint pop exch lineto} {}] bind def
+/bargraph [{} {exch GR sub exch dup
+ XRNG 0 get 0 gtrans exch pop % y=0
+ exch sub GD exch rectstroke} {}] bind def
% Solid round dot.
/disc [{GD setlinewidth 1 setlinecap}
@@ -97,14 +102,14 @@ plotdict begin
{}] bind def
% Triangle pointing upward
/triup [{}
- {2 copy GR 1.12 mul add moveto GR neg GR -1.62 mul rlineto
- GR 2 mul 0 rlineto GR neg GR 1.62 mul rlineto
+ {GR 1.12 mul add moveto GR neg GR -1.62 mul rlineto
+ GR 2 mul 0 rlineto GR neg GR 1.62 mul rlineto
closepath}
{}] bind def
% Triangle pointing downward
/tridown [{}
- {2 copy GR 1.12 mul sub moveto GR neg GR 1.62 mul rlineto
- GR 2 mul 0 rlineto GR neg GR -1.62 mul rlineto
+ {GR 1.12 mul sub moveto GR neg GR 1.62 mul rlineto
+ GR 2 mul 0 rlineto GR neg GR -1.62 mul rlineto
closepath}
{}] bind def
/pentagon [{}
@@ -148,9 +153,6 @@ plotdict begin
grestore
} bind def
-/whole-page
-{clippath pathbbox 2 index sub exch 3 index sub exch 4 array astore} bind def
-
/partition-page
{ /YPARTS exch def /XPARTS exch def /WPAGE exch def
/XWID WPAGE 2 get XPARTS div def /YHIT WPAGE 3 get YPARTS div def
@@ -172,8 +174,8 @@ plotdict begin
{ /YRNG exch def /XRNG exch def /graphrect exch def
/PLOT-bmargin pointsize 2.4 mul def
/PLOT-tmargin pointsize 2.4 mul def
- /PLOT-lmargin (-.0123456789) stringwidth pop pointsize 1.2 mul add def
- /PLOT-rmargin (-.0123456789) stringwidth pop pointsize 1.2 mul add def
+ /PLOT-lmargin lmargin-template stringwidth pop pointsize 1.2 mul add def
+ /PLOT-rmargin rmargin-template stringwidth pop pointsize 1.2 mul add def
/plotrect [ graphrect 0 get PLOT-lmargin add
graphrect 1 get PLOT-bmargin add
graphrect 2 get PLOT-lmargin sub PLOT-rmargin sub
@@ -186,7 +188,7 @@ plotdict begin
/YTSCL plotrect 3 get YRNG aload pop exch sub find-tick-scale def
/YSTEP YTSCL 0 get 3 mod 0 eq {6} {8} ifelse 5 mul yuntrans def
/XTSCL plotrect 2 get XRNG aload pop exch sub find-tick-scale def
- /XSTEP XTSCL 0 get 3 mod 0 eq {6} {8} ifelse 10 mul xuntrans def
+ /XSTEP XTSCL 0 get 3 mod 0 eq {12} {10} ifelse 5 mul xuntrans def
/YSTEPH YSTEP 2 div def
/XSTEPH XSTEP 2 div def
} bind def
@@ -329,8 +331,16 @@ bind def
/fill-rect {aload pop rectfill} bind def
/clip-to-rect {aload pop rectclip} bind def
+/gstack [] def
+/gpush {gsave /gstack [ gstack pointsize glyphsize ] def} bind def
+/gpop {/gstack gstack aload pop /glyphsize exch def /pointsize exch def def grestore} bind def
+
% Default parameters
+% The legend-templates are strings used to reserve horizontal space
+/lmargin-template (-.0123456789) def
+/rmargin-template (-.0123456789) def
+
% glyphsize is the graphic-glyph size; GR, graphic radius, is
% glyphsize/2. Line width, set by "setlinewidth", must be much less
% than glyphsize for readable glyphs.