File: plot.ps

package info (click to toggle)
mit-scheme 12.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,300 kB
  • sloc: lisp: 781,881; xml: 425,435; ansic: 86,059; sh: 10,135; makefile: 2,501; asm: 2,121; csh: 1,143
file content (184 lines) | stat: -rw-r--r-- 4,927 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
% Derived axis parameters.
/awidth axmax axmin sub def
/aheight aymax aymin sub def

% 1pt margin on either side for arrow heads.
/a2bbx bbwidth 2 sub awidth div def
/a2bby bbheight 2 sub aheight div def

/a2bb                           % xa ya => xbb ybb
{
    exch a2bbx mul              % ya xbb
    exch a2bby mul              % xbb ybb
} def

/Ta2bb                          % Txa Tya => Txbb Tybb
{
    exch a2bbx Tconst Tmul      % Tyf Tx2bb
    exch a2bby Tconst Tmul      % Txbb Tybb
} def

/arrowhead                      % x y angle => ---
{
    gsave
        1 setlinecap
        newpath
        3 1 roll                % angle x y
        moveto rotate
        -2 2 rmoveto 2 -2 rlineto -2 -2 rlineto
        stroke
    grestore
} def

/ticku 5 def                    % tick size in pt

/tick                           % xa ya tx ty => ---
{
    exch ticku mul              % xa ya ty dxbb
    exch ticku mul              % xa ya dxbb dybb
    4 2 roll a2bb               % dxbb dybb xbb ybb
    gsave newpath moveto rlineto stroke grestore
} def

/ticklabel                      % v xa ya dxbb dybb => ---
{
    4 2 roll a2bb               % v dxbb dybb xbb ybb
    newpath moveto rlineto show
} def

/xticklabel                     % x ty => ---
{
    exch dup                    % ty x x
    4 string cvs                % ty x xs
    3 -1 roll                   % x xs ty
    xticklabelstr
} def

/xticklabelstr                  % x xs ty => ---
{
    3 1 roll                    % ty x xs
    gsave
        newpath 0 0 moveto
        dup true charpath
        pathbbox                % ty x xs llx lly urx ury
    grestore
    3 -1 roll sub               % ty x xs llx urx ury-lly
    3 1 roll exch add           % ty x xs ury-lly urx+llx
    2 div                       % ty x xs ury-lly (urx+llx)/2
    0 exch sub                  % ty x xs ury-lly -(urx+llx)/2
    exch                        % ty x xs -(urx+llx)/2 ury-lly
    4 index 0 lt {
        ticku 2 mul add
    } {
        pop ticku 2 mul
    } ifelse                    % ty x xs -w/2 h
    5 -1 roll mul               % x xs -w/2 h*ty
    4 -1 roll                   % xs -w/2 h*ty x
    0                           % xs -w/2 h*ty x y
    4 2 roll                    % xs x y -w/2 h*ty
    ticklabel
} def

/yticklabel                     % y tx => ---
{
    exch dup                    % tx y y
    4 string cvs                % tx y ys
    3 -1 roll                   % y ys tx
    yticklabelstr
} def

/yticklabelstr                  % y ys tx => ---
{
    3 1 roll                    % tx y ys
    gsave
        newpath 0 0 moveto
        dup true charpath
        pathbbox                % tx y ys llx lly urx ury
    grestore
    3 -1 roll add 2 div         % tx y ys llx urx (ury+lly)/2
    0 exch sub                  % tx y ys llx urx -(ury+lly)/2
    3 1 roll exch sub           % tx y ys -(ury+lly)/2 urx-llx
    4 index 0 lt {
        ticku 2 mul add
    } {
        pop ticku 2 mul
    } ifelse                    % tx y ys -h/2 w
    5 -1 roll mul               % y ys -h/2 w*tx
    exch                        % y ys w*tx -h/2
    4 -1 roll                   % ys w*tx -h/2 y
    0                           % ys w*tx -h/2 y x
    exch                        % ys w*tx -h/2 x y
    4 2 roll                    % ys x y w*tx -h/2
    ticklabel
} def

/reencodefont                   % name font proc => font'
{
    exch dup length dict copy   % name proc font'
    dup /Encoding get           % name proc font' encoding
    dup length array copy       % name proc font' encoding'
    3 -1 roll exec              % name font' encoding'
    1 index exch                % name font' encoding' font'
    /Encoding exch put          % name font'
    definefont
} def

/setupplotbbox
{
    % Clip to bounding box.
    newpath
    llx lly moveto llx ury lineto urx ury lineto urx lly lineto closepath
    clip

    % Center coordinates with 1pt margin for arrow heads.
    0 axmin sub 0 aymin sub a2bb 1 add exch 1 add exch translate
} def

/setupasymptote
{
    0.5 setgray
    0.4 setlinewidth
    [4 4] 1 setdash
} def

/setupaxes
{
    0.4 setlinewidth
    /Times-Roman-Numeric
        /Times-Roman findfont
        { dup 45 /minus put } reencodefont % replace hyphen by minus
    10 scalefont setfont
} def

/setupaxesgreek
{
    0.4 setlinewidth
    /Symbol-Numeric
        /Symbol findfont
        { dup 45 /minus put } reencodefont % replace hyphen by minus
    10 scalefont setfont
} def

/drawaxes
{
    newpath axmin 0 a2bb moveto axmax 0 a2bb lineto stroke
    axmax 0 a2bb 0 arrowhead
    axmin 0 a2bb 180 arrowhead
    newpath 0 aymin a2bb moveto 0 aymax a2bb lineto stroke
    0 aymax a2bb 90 arrowhead
    0 aymin a2bb -90 arrowhead
} def

/setupfunctionplot
{
    0 0 1 setrgbcolor
    0.6 setlinewidth
    1 setlinecap
} def

/setupconditionnumberplot
{
    1 0 0 setrgbcolor
    0.6 setlinewidth
    1 setlinecap
} def