rubypost 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +0 -0
- data/doc/created.rid +1 -1
- data/doc/fr_class_index.html +6 -0
- data/doc/fr_file_index.html +1 -0
- data/doc/fr_method_index.html +170 -144
- data/doc/index.html +0 -0
- data/lib/draw.rb +0 -0
- data/lib/drawable.rb +10 -2
- data/lib/graph.rb +0 -0
- data/lib/label.rb +0 -0
- data/lib/objects.rb +7 -11
- data/lib/options.rb +0 -0
- data/lib/redefine_float_to_s_for_metapost.rb +2 -1
- data/lib/revert_float_to_s.rb +0 -0
- data/lib/rubypost.rb +0 -0
- data/lib/simpleplot.rb +234 -0
- data/tests/test_circle.rb +0 -0
- data/tests/test_clip.rb +0 -0
- data/tests/test_graph.rb +0 -1
- data/tests/test_label.rb +0 -0
- data/tests/test_pair.rb +0 -0
- data/tests/test_path.rb +1 -2
- data/tests/test_picture.rb +0 -1
- data/tests/test_simpleplot.rb +49 -0
- data/tests/test_square.rb +0 -1
- data/tests/testsimpleplot-1.mps +33 -0
- data/tests/testsimpleplot-2.mps +238 -0
- data/tests/testsimpleplot.log +4 -0
- data/tests/testsimpleplot.mp +75 -0
- data/tests/testsimpleplot.mpx +121 -0
- metadata +26 -19
data/lib/simpleplot.rb
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
|
2
|
+
module RubyPost
|
3
|
+
|
4
|
+
|
5
|
+
class SimplePlot < Picture
|
6
|
+
|
7
|
+
#initialise with height and width in centemeters
|
8
|
+
def initialize(width, height)
|
9
|
+
super()
|
10
|
+
@plot_array = Array.new
|
11
|
+
@height = height
|
12
|
+
@width = width
|
13
|
+
#axes set by default
|
14
|
+
setaxes(-1,1,-1,1)
|
15
|
+
@xtickstr = "\n"
|
16
|
+
@ytickstr = "\n"
|
17
|
+
@xlabel = "\n"
|
18
|
+
@ylabel = "\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
#the scale factors are decided by the very last plot you add
|
22
|
+
#you can adjust it with the axes command
|
23
|
+
def add_plot(plot)
|
24
|
+
@plot_array.push(plot)
|
25
|
+
setaxesfor(plot)
|
26
|
+
end
|
27
|
+
|
28
|
+
def setaxesfor(plot)
|
29
|
+
puts plot.xmin
|
30
|
+
puts plot.ymax
|
31
|
+
setaxes(plot.xmin, plot.xmax, plot.ymin, plot.ymax)
|
32
|
+
end
|
33
|
+
|
34
|
+
def setaxes(xmin, xmax, ymin, ymax)
|
35
|
+
@xmax = xmax
|
36
|
+
@xmin = xmin
|
37
|
+
@ymax = ymax
|
38
|
+
@ymin = ymin
|
39
|
+
|
40
|
+
@xscale = @width.to_f/(xmax - xmin)
|
41
|
+
@yscale = @height.to_f/(ymax - ymin)
|
42
|
+
end
|
43
|
+
|
44
|
+
#set xtick marks, a is an array of tick position and label is the
|
45
|
+
#text for each tick. func describes whether a tick should be put on
|
46
|
+
#the top or the bottom. func(x) should return positive for on the bottom
|
47
|
+
#and negative for on the top.
|
48
|
+
def xticks(x, label=nil, func = lambda {|v| 1} )
|
49
|
+
if(label==nil) then label = x.map{|v| latex(v.to_s) } end
|
50
|
+
lplace = x.map{ |v| if(func.call(v) < 0) then 'urt' else 'lrt' end }
|
51
|
+
@xtickstr = ''
|
52
|
+
x.each_index{ |i|
|
53
|
+
@xtickstr = @xtickstr + 'draw ((0,-0.1cm)--(0,0.1cm)) shifted (' + (x[i]*@xscale).to_s + "cm, 0);\n"
|
54
|
+
@xtickstr = @xtickstr + 'label.' + lplace[i].to_s + '(' + label[i] + ' ,(' + (x[i]*@xscale).to_s + "cm, 0));\n"
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
#set ytick marks, a is an array of tick position and laebl is the text
|
59
|
+
def yticks(y, label=nil )
|
60
|
+
if(label==nil) then label = y.map{|v| latex(v.to_s) } end
|
61
|
+
@ytickstr = ''
|
62
|
+
y.each_index{ |i|
|
63
|
+
@ytickstr = @ytickstr + 'draw ((-0.1.cm,0)--(0.1cm,0)) shifted (0,' + (y[i]*@yscale).to_s + "cm);\n"
|
64
|
+
@ytickstr = @ytickstr + 'label.rt(' + label[i] + ' ,(0,' + (y[i]*@yscale).to_s + "cm));\n"
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
def xlabel(t)
|
69
|
+
@xlabel = 'label.top(' + t + ', (' + (@xscale*@xmax + 0.6).to_s + "cm,0));\n"
|
70
|
+
end
|
71
|
+
|
72
|
+
def ylabel(t)
|
73
|
+
@ylabel = 'label.rt(' + t + ', (0, ' + (@yscale*@ymax + 0.6).to_s + "cm));\n"
|
74
|
+
end
|
75
|
+
|
76
|
+
def precompile
|
77
|
+
str = "picture " + @name + ";\n"
|
78
|
+
|
79
|
+
#draw the axes
|
80
|
+
str = str + "\n%draw the axes\n"
|
81
|
+
str = str + 'draw ((' + (@xscale*@xmax + 0.6).to_s + 'cm,0)--('+ (@xscale*@xmin - 0.3).to_s + "cm,0));\n"
|
82
|
+
str = str + 'draw ((0, ' + (@yscale*@ymin - 0.3).to_s + 'cm)--(0, ' + (@yscale*@ymax + 0.6).to_s + "cm));\n"
|
83
|
+
|
84
|
+
str = str + "\n%draw xticks\n"
|
85
|
+
str = str + @xtickstr
|
86
|
+
str = str + "\n%draw yticks\n"
|
87
|
+
str = str + @ytickstr
|
88
|
+
str = str + "\n%draw xticks\n"
|
89
|
+
str = str + @xlabel
|
90
|
+
str = str + "\n%draw yticks\n"
|
91
|
+
str = str + @ylabel
|
92
|
+
|
93
|
+
|
94
|
+
#draw each plot componenet.
|
95
|
+
@plot_array.each{|p|
|
96
|
+
puts p.class
|
97
|
+
puts p.ymax
|
98
|
+
str = str + p.compilewithscale(@xscale, @yscale) }
|
99
|
+
|
100
|
+
str = str + @name + " := currentpicture; currentpicture := " + @@org_picture + ";\n"
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
class AbstractPlot < BaseDrawCommand
|
106
|
+
|
107
|
+
attr_writer :x, :y
|
108
|
+
|
109
|
+
def initialize()
|
110
|
+
super()
|
111
|
+
end
|
112
|
+
|
113
|
+
def xmax
|
114
|
+
@x.max
|
115
|
+
end
|
116
|
+
|
117
|
+
def xmin
|
118
|
+
@x.min
|
119
|
+
end
|
120
|
+
|
121
|
+
def ymax
|
122
|
+
@y.max
|
123
|
+
end
|
124
|
+
|
125
|
+
def ymin
|
126
|
+
@y.min
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
class LinePlot < AbstractPlot
|
132
|
+
|
133
|
+
#Intitalise with two arrays of the same size.
|
134
|
+
def initialize(x, y)
|
135
|
+
super()
|
136
|
+
@x = x
|
137
|
+
@y = y
|
138
|
+
end
|
139
|
+
|
140
|
+
def compile
|
141
|
+
@p = Path.new
|
142
|
+
@x.each_index{ |i| @p.add_pair(Pair.new(@x[i].cm, @y[i].cm)) }
|
143
|
+
'draw ' + @p.compile + ' ' + compile_options + ";\n"
|
144
|
+
end
|
145
|
+
|
146
|
+
def compilewithscale(xscale, yscale)
|
147
|
+
@p = Path.new
|
148
|
+
@x.each_index{ |i| @p.add_pair(Pair.new((@x[i]*xscale).cm, (@y[i]*yscale).cm)) }
|
149
|
+
'draw ' + @p.compile + ' ' + compile_options + ";\n"
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
class CurvedPlot < AbstractPlot
|
155
|
+
|
156
|
+
#Intitalise with two arrays of the same size.
|
157
|
+
def initialize(x, y)
|
158
|
+
super()
|
159
|
+
@x = x
|
160
|
+
@y = y
|
161
|
+
end
|
162
|
+
|
163
|
+
def compile
|
164
|
+
@p = Path.new.curved
|
165
|
+
@x.each_index{ |i| @p.add_pair(Pair.new(@x[i].cm, @y[i].cm)) }
|
166
|
+
'draw ' + @p.compile + ' ' + compile_options + ";\n"
|
167
|
+
end
|
168
|
+
|
169
|
+
def compilewithscale(xscale, yscale)
|
170
|
+
@p = Path.new.curved
|
171
|
+
@x.each_index{ |i| @p.add_pair(Pair.new((@x[i]*xscale).cm, (@y[i]*yscale).cm)) }
|
172
|
+
'draw ' + @p.compile + ' ' + compile_options + ";\n"
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
class ImpulsePlot < AbstractPlot
|
178
|
+
|
179
|
+
#Intitalise with two arrays of the same size.
|
180
|
+
def initialize(x, y)
|
181
|
+
super()
|
182
|
+
@x = x
|
183
|
+
@y = y
|
184
|
+
end
|
185
|
+
|
186
|
+
def compile
|
187
|
+
str = ''
|
188
|
+
@x.each_index{ |i|
|
189
|
+
str = str + 'drawarrow (' + @x[i].to_s + 'cm, 0)--(' + @x[i].to_s + 'cm, ' + @y[i].to_s + 'cm) ' + compile_options + ";\n"
|
190
|
+
}
|
191
|
+
return str
|
192
|
+
end
|
193
|
+
|
194
|
+
def compilewithscale(xscale, yscale)
|
195
|
+
str = ''
|
196
|
+
@x.each_index{ |i|
|
197
|
+
str = str + 'drawarrow (' + (@x[i]*xscale).to_s + 'cm, 0)--(' + (@x[i]*xscale).to_s + 'cm, ' + (@y[i]*yscale).to_s + 'cm) ' + compile_options + ";\n"
|
198
|
+
}
|
199
|
+
return str
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
class StemPlot < AbstractPlot
|
205
|
+
|
206
|
+
#Intitalise with two arrays of the same size.
|
207
|
+
def initialize(x, y)
|
208
|
+
super()
|
209
|
+
@x = x
|
210
|
+
@y = y
|
211
|
+
end
|
212
|
+
|
213
|
+
def compile
|
214
|
+
str = ''
|
215
|
+
@x.each_index{ |i|
|
216
|
+
str = str + 'draw (' + @x[i].to_s + 'cm, 0)--(' + @x[i].to_s + 'cm, ' + @y[i].to_s + 'cm) ' + compile_options + ";\n"
|
217
|
+
str = str + 'fill fullcircle scaled (0.1cm) shifted (' + @x[i].to_s + 'cm, ' + @y[i].to_s + 'cm) ' + compile_options + ";\n"
|
218
|
+
}
|
219
|
+
return str
|
220
|
+
end
|
221
|
+
|
222
|
+
def compilewithscale(xscale, yscale)
|
223
|
+
str = ''
|
224
|
+
@x.each_index{ |i|
|
225
|
+
str = str + 'draw (' + (@x[i]*xscale).to_s + 'cm, 0)--(' + (@x[i]*xscale).to_s + 'cm, ' + (@y[i]*yscale).to_s + 'cm) ' + compile_options + ";\n"
|
226
|
+
str = str + 'fill fullcircle scaled (0.1cm) shifted (' + (@x[i]*xscale).to_s + 'cm, ' + (@y[i]*yscale).to_s + 'cm) ' + compile_options + ";\n"
|
227
|
+
}
|
228
|
+
return str
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
end
|
data/tests/test_circle.rb
CHANGED
File without changes
|
data/tests/test_clip.rb
CHANGED
File without changes
|
data/tests/test_graph.rb
CHANGED
data/tests/test_label.rb
CHANGED
File without changes
|
data/tests/test_pair.rb
CHANGED
File without changes
|
data/tests/test_path.rb
CHANGED
data/tests/test_picture.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
#require 'rubypost'
|
2
|
+
|
3
|
+
require '../lib/objects'
|
4
|
+
require '../lib/drawable'
|
5
|
+
require '../lib/draw'
|
6
|
+
require '../lib/options'
|
7
|
+
require '../lib/simpleplot'
|
8
|
+
#require '../lib/graph'
|
9
|
+
|
10
|
+
include RubyPost
|
11
|
+
|
12
|
+
#note, can't use underscores in filenames if you are going
|
13
|
+
#to use File#view. tex mproof breaks
|
14
|
+
file = RubyPost::File.new('testsimpleplot')
|
15
|
+
|
16
|
+
x = (-3..3).to_a
|
17
|
+
y = x.map { |v| v**2 }
|
18
|
+
|
19
|
+
lplot = CurvedPlot.new(x,y).add_option(Colour.new(1.0,0,0))
|
20
|
+
splot = LinePlot.new(x,y).add_option(Colour.new(1.0,0,0))
|
21
|
+
iplot = ImpulsePlot.new(x,y).add_option(Colour.new(0,1.0,0))
|
22
|
+
stemplot = StemPlot.new(x,y).add_option(Colour.new(0,0,1.0))
|
23
|
+
|
24
|
+
#draw a curved path
|
25
|
+
fig1 = Figure.new
|
26
|
+
file.add_figure(fig1)
|
27
|
+
fig1.add_drawable(lplot)
|
28
|
+
|
29
|
+
|
30
|
+
simpplot = SimplePlot.new(10, 5)
|
31
|
+
simpplot.add_plot(lplot)
|
32
|
+
simpplot.add_plot(splot)
|
33
|
+
simpplot.add_plot(iplot)
|
34
|
+
simpplot.add_plot(stemplot)
|
35
|
+
simpplot.xticks(x)
|
36
|
+
simpplot.yticks([3,6,9])
|
37
|
+
simpplot.xlabel(latex('t'))
|
38
|
+
simpplot.ylabel(latex('X(t)'))
|
39
|
+
|
40
|
+
|
41
|
+
#draw a curved path
|
42
|
+
fig2 = Figure.new
|
43
|
+
file.add_figure(fig2)
|
44
|
+
fig2.add_drawable(Draw.new(simpplot))
|
45
|
+
|
46
|
+
|
47
|
+
puts file.compile_to_string
|
48
|
+
file.compile
|
49
|
+
#file.view
|
data/tests/test_square.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
%!PS-Adobe-3.0 EPSF-3.0
|
2
|
+
%%BoundingBox: -86 -1 86 256
|
3
|
+
%%HiResBoundingBox: -85.28935 -0.25 85.28935 255.36806
|
4
|
+
%%Creator: MetaPost 1.208
|
5
|
+
%%CreationDate: 2010.08.02:2217
|
6
|
+
%%Pages: 1
|
7
|
+
%%DocumentResources: procset mpost-minimal
|
8
|
+
%%DocumentSuppliedResources: procset mpost-minimal
|
9
|
+
%%EndComments
|
10
|
+
%%BeginProlog
|
11
|
+
%%BeginResource: procset mpost-minimal
|
12
|
+
/bd{bind def}bind def/fshow {exch findfont exch scalefont setfont show}bd
|
13
|
+
/fcp{findfont dup length dict begin{1 index/FID ne{def}{pop pop}ifelse}forall}bd
|
14
|
+
/fmc{FontMatrix dup length array copy dup dup}bd/fmd{/FontMatrix exch def}bd
|
15
|
+
/Amul{4 -1 roll exch mul 1000 div}bd/ExtendFont{fmc 0 get Amul 0 exch put fmd}bd
|
16
|
+
/ScaleFont{dup fmc 0 get Amul 0 exch put dup dup 3 get Amul 3 exch put fmd}bd
|
17
|
+
/SlantFont{fmc 2 get dup 0 eq{pop 1}if Amul FontMatrix 0 get mul 2 exch put fmd}bd
|
18
|
+
%%EndResource
|
19
|
+
%%EndProlog
|
20
|
+
%%BeginSetup
|
21
|
+
%%EndSetup
|
22
|
+
%%Page: 1 1
|
23
|
+
1 0 0 setrgbcolor 0 0.5 dtransform truncate idtransform setlinewidth pop
|
24
|
+
[] 0 setdash 1 setlinecap 1 setlinejoin 10 setmiterlimit
|
25
|
+
newpath -85.03935 255.11806 moveto
|
26
|
+
-79.06273 207.2454 -69.58858 159.87465 -56.6929 113.3858 curveto
|
27
|
+
-48.70035 84.57266 -39.40112 56.13019 -28.34645 28.34645 curveto
|
28
|
+
-22.77745 14.34987 -14.41289 0 0 0 curveto
|
29
|
+
14.41289 0 22.77745 14.34987 28.34645 28.34645 curveto
|
30
|
+
39.40111 56.13019 48.70035 84.57266 56.6929 113.3858 curveto
|
31
|
+
69.58858 159.87465 79.06273 207.2454 85.03935 255.11806 curveto stroke
|
32
|
+
showpage
|
33
|
+
%%EOF
|
@@ -0,0 +1,238 @@
|
|
1
|
+
%!PS-Adobe-3.0 EPSF-3.0
|
2
|
+
%%BoundingBox: -151 -9 161 164
|
3
|
+
%%HiResBoundingBox: -150.48628 -8.75403 160.67749 163.72165
|
4
|
+
%%Creator: MetaPost 1.208
|
5
|
+
%%CreationDate: 2010.08.02:2217
|
6
|
+
%%Pages: 1
|
7
|
+
%%DocumentResources: procset mpost-minimal
|
8
|
+
%%+ font CMR10
|
9
|
+
%%DocumentSuppliedResources: procset mpost-minimal
|
10
|
+
%%DocumentNeededResources: font CMR10
|
11
|
+
%%IncludeResource: font CMR10
|
12
|
+
%%EndComments
|
13
|
+
%%BeginProlog
|
14
|
+
%%BeginResource: procset mpost-minimal
|
15
|
+
/bd{bind def}bind def/fshow {exch findfont exch scalefont setfont show}bd
|
16
|
+
/fcp{findfont dup length dict begin{1 index/FID ne{def}{pop pop}ifelse}forall}bd
|
17
|
+
/fmc{FontMatrix dup length array copy dup dup}bd/fmd{/FontMatrix exch def}bd
|
18
|
+
/Amul{4 -1 roll exch mul 1000 div}bd/ExtendFont{fmc 0 get Amul 0 exch put fmd}bd
|
19
|
+
/ScaleFont{dup fmc 0 get Amul 0 exch put dup dup 3 get Amul 3 exch put fmd}bd
|
20
|
+
/SlantFont{fmc 2 get dup 0 eq{pop 1}if Amul FontMatrix 0 get mul 2 exch put fmd}bd
|
21
|
+
%%EndResource
|
22
|
+
%%EndProlog
|
23
|
+
%%BeginSetup
|
24
|
+
/cmr10 /CMR10 def
|
25
|
+
%%EndSetup
|
26
|
+
%%Page: 1 1
|
27
|
+
0 0 0 setrgbcolor 0 0.5 dtransform truncate idtransform setlinewidth pop
|
28
|
+
[] 0 setdash 1 setlinecap 1 setlinejoin 10 setmiterlimit
|
29
|
+
newpath 158.7403 0 moveto
|
30
|
+
-150.23628 0 lineto stroke
|
31
|
+
0.5 0 dtransform exch truncate exch idtransform pop setlinewidth
|
32
|
+
newpath 0 -8.50403 moveto
|
33
|
+
0 158.7403 lineto stroke
|
34
|
+
newpath -141.73225 -2.83482 moveto
|
35
|
+
-141.73225 2.83482 lineto stroke
|
36
|
+
-139.63226 -8.52039 moveto
|
37
|
+
(-3) cmr10 9.96265 fshow
|
38
|
+
newpath -94.48802 -2.83482 moveto
|
39
|
+
-94.48802 2.83482 lineto stroke
|
40
|
+
-92.38803 -8.52039 moveto
|
41
|
+
(-2) cmr10 9.96265 fshow
|
42
|
+
newpath -47.24423 -2.83482 moveto
|
43
|
+
-47.24423 2.83482 lineto stroke
|
44
|
+
-45.14424 -8.52039 moveto
|
45
|
+
(-1) cmr10 9.96265 fshow
|
46
|
+
newpath 0 -2.83482 moveto
|
47
|
+
0 2.83482 lineto stroke
|
48
|
+
2.09999 -8.52039 moveto
|
49
|
+
(0) cmr10 9.96265 fshow
|
50
|
+
newpath 47.24423 -2.83482 moveto
|
51
|
+
47.24423 2.83482 lineto stroke
|
52
|
+
49.34422 -8.52039 moveto
|
53
|
+
(1) cmr10 9.96265 fshow
|
54
|
+
newpath 94.48802 -2.83482 moveto
|
55
|
+
94.48802 2.83482 lineto stroke
|
56
|
+
96.58801 -8.52039 moveto
|
57
|
+
(2) cmr10 9.96265 fshow
|
58
|
+
newpath 141.73225 -2.83482 moveto
|
59
|
+
141.73225 2.83482 lineto stroke
|
60
|
+
143.83224 -8.52039 moveto
|
61
|
+
(3) cmr10 9.96265 fshow
|
62
|
+
0 0.5 dtransform truncate idtransform setlinewidth pop
|
63
|
+
newpath -2.83482 47.24423 moveto
|
64
|
+
2.83482 47.24423 lineto stroke
|
65
|
+
3 44.03403 moveto
|
66
|
+
(3) cmr10 9.96265 fshow
|
67
|
+
newpath -2.83482 94.48802 moveto
|
68
|
+
2.83482 94.48802 lineto stroke
|
69
|
+
3 91.27782 moveto
|
70
|
+
(6) cmr10 9.96265 fshow
|
71
|
+
newpath -2.83482 141.73225 moveto
|
72
|
+
2.83482 141.73225 lineto stroke
|
73
|
+
3 138.52205 moveto
|
74
|
+
(9) cmr10 9.96265 fshow
|
75
|
+
156.80309 3 moveto
|
76
|
+
(t) cmr10 9.96265 fshow
|
77
|
+
3 156.24965 moveto
|
78
|
+
(X\(t\)) cmr10 9.96265 fshow
|
79
|
+
1 0 0 setrgbcolor
|
80
|
+
newpath -141.73225 141.73225 moveto
|
81
|
+
-128.78806 113.90198 -112.95288 87.51018 -94.48802 62.99231 curveto
|
82
|
+
-80.99356 45.0742 -65.99892 28.09071 -47.24423 15.74808 curveto
|
83
|
+
-33.07912 6.42587 -16.96332 0 0 0 curveto
|
84
|
+
16.96332 0 33.07912 6.42587 47.24423 15.74808 curveto
|
85
|
+
65.99892 28.09071 80.99356 45.0742 94.48802 62.99231 curveto
|
86
|
+
112.95288 87.51018 128.78804 113.90198 141.73225 141.73225 curveto stroke
|
87
|
+
newpath -141.73225 141.73225 moveto
|
88
|
+
-94.48802 62.99231 lineto
|
89
|
+
-47.24423 15.74808 lineto
|
90
|
+
0 0 lineto
|
91
|
+
47.24423 15.74808 lineto
|
92
|
+
94.48802 62.99231 lineto
|
93
|
+
141.73225 141.73225 lineto stroke
|
94
|
+
0 1 0 setrgbcolor 0.5
|
95
|
+
0 dtransform exch truncate exch idtransform pop setlinewidth
|
96
|
+
newpath -141.73225 0 moveto
|
97
|
+
-141.73225 141.73225 lineto stroke
|
98
|
+
0 0.5 dtransform truncate idtransform setlinewidth pop
|
99
|
+
newpath -140.20113 138.03589 moveto
|
100
|
+
-141.73225 141.73225 lineto
|
101
|
+
-143.26338 138.03589 lineto
|
102
|
+
closepath
|
103
|
+
gsave fill grestore stroke
|
104
|
+
0.5 0 dtransform exch truncate exch idtransform pop setlinewidth
|
105
|
+
newpath -94.48802 0 moveto
|
106
|
+
-94.48802 62.99231 lineto stroke
|
107
|
+
0 0.5 dtransform truncate idtransform setlinewidth pop
|
108
|
+
newpath -92.95709 59.2964 moveto
|
109
|
+
-94.48802 62.99231 lineto
|
110
|
+
-96.01895 59.2964 lineto
|
111
|
+
closepath
|
112
|
+
gsave fill grestore stroke
|
113
|
+
0.5 0 dtransform exch truncate exch idtransform pop setlinewidth
|
114
|
+
newpath -47.24423 0 moveto
|
115
|
+
-47.24423 15.74808 lineto stroke
|
116
|
+
0 0.5 dtransform truncate idtransform setlinewidth pop
|
117
|
+
newpath -45.71347 12.0526 moveto
|
118
|
+
-47.24423 15.74808 lineto
|
119
|
+
-48.775 12.0526 lineto
|
120
|
+
closepath
|
121
|
+
gsave fill grestore stroke
|
122
|
+
newpath 0 0 moveto
|
123
|
+
0 0 lineto stroke
|
124
|
+
newpath 0 0 moveto
|
125
|
+
closepath
|
126
|
+
gsave fill grestore stroke
|
127
|
+
0.5 0 dtransform exch truncate exch idtransform pop setlinewidth
|
128
|
+
newpath 47.24423 0 moveto
|
129
|
+
47.24423 15.74808 lineto stroke
|
130
|
+
0 0.5 dtransform truncate idtransform setlinewidth pop
|
131
|
+
newpath 48.775 12.0526 moveto
|
132
|
+
47.24423 15.74808 lineto
|
133
|
+
45.71347 12.0526 lineto
|
134
|
+
closepath
|
135
|
+
gsave fill grestore stroke
|
136
|
+
0.5 0 dtransform exch truncate exch idtransform pop setlinewidth
|
137
|
+
newpath 94.48802 0 moveto
|
138
|
+
94.48802 62.99231 lineto stroke
|
139
|
+
0 0.5 dtransform truncate idtransform setlinewidth pop
|
140
|
+
newpath 96.01895 59.2964 moveto
|
141
|
+
94.48802 62.99231 lineto
|
142
|
+
92.95709 59.2964 lineto
|
143
|
+
closepath
|
144
|
+
gsave fill grestore stroke
|
145
|
+
0.5 0 dtransform exch truncate exch idtransform pop setlinewidth
|
146
|
+
newpath 141.73225 0 moveto
|
147
|
+
141.73225 141.73225 lineto stroke
|
148
|
+
0 0.5 dtransform truncate idtransform setlinewidth pop
|
149
|
+
newpath 143.26338 138.03589 moveto
|
150
|
+
141.73225 141.73225 lineto
|
151
|
+
140.20113 138.03589 lineto
|
152
|
+
closepath
|
153
|
+
gsave fill grestore stroke
|
154
|
+
0 0 1 setrgbcolor 0.5
|
155
|
+
0 dtransform exch truncate exch idtransform pop setlinewidth
|
156
|
+
newpath -141.73225 0 moveto
|
157
|
+
-141.73225 141.73225 lineto stroke
|
158
|
+
newpath -140.31483 141.73225 moveto
|
159
|
+
-140.31483 142.10818 -140.4642 142.46869 -140.73001 142.7345 curveto
|
160
|
+
-140.99582 143.0003 -141.35632 143.14967 -141.73225 143.14967 curveto
|
161
|
+
-142.10818 143.14967 -142.46869 143.0003 -142.7345 142.7345 curveto
|
162
|
+
-143.0003 142.46869 -143.14967 142.10818 -143.14967 141.73225 curveto
|
163
|
+
-143.14967 141.35632 -143.0003 140.99582 -142.7345 140.73001 curveto
|
164
|
+
-142.46869 140.4642 -142.10818 140.31483 -141.73225 140.31483 curveto
|
165
|
+
-141.35632 140.31483 -140.99582 140.4642 -140.73001 140.73001 curveto
|
166
|
+
-140.4642 140.99582 -140.31483 141.35632 -140.31483 141.73225 curveto closepath
|
167
|
+
fill
|
168
|
+
newpath -94.48802 0 moveto
|
169
|
+
-94.48802 62.99231 lineto stroke
|
170
|
+
newpath -93.0706 62.99231 moveto
|
171
|
+
-93.0706 63.36824 -93.21997 63.72874 -93.48578 63.99455 curveto
|
172
|
+
-93.75159 64.26036 -94.11209 64.40973 -94.48802 64.40973 curveto
|
173
|
+
-94.86395 64.40973 -95.22446 64.26036 -95.49026 63.99455 curveto
|
174
|
+
-95.75607 63.72874 -95.90544 63.36824 -95.90544 62.99231 curveto
|
175
|
+
-95.90544 62.61638 -95.75607 62.25587 -95.49026 61.99007 curveto
|
176
|
+
-95.22446 61.72426 -94.86395 61.57489 -94.48802 61.57489 curveto
|
177
|
+
-94.11209 61.57489 -93.75159 61.72426 -93.48578 61.99007 curveto
|
178
|
+
-93.21997 62.25587 -93.0706 62.61638 -93.0706 62.99231 curveto closepath fill
|
179
|
+
newpath -47.24423 0 moveto
|
180
|
+
-47.24423 15.74808 lineto stroke
|
181
|
+
newpath -45.82681 15.74808 moveto
|
182
|
+
-45.82681 16.12401 -45.97618 16.48451 -46.24199 16.75032 curveto
|
183
|
+
-46.5078 17.01613 -46.8683 17.1655 -47.24423 17.1655 curveto
|
184
|
+
-47.62016 17.1655 -47.98067 17.01613 -48.24648 16.75032 curveto
|
185
|
+
-48.51228 16.48451 -48.66165 16.12401 -48.66165 15.74808 curveto
|
186
|
+
-48.66165 15.37215 -48.51228 15.01164 -48.24648 14.74583 curveto
|
187
|
+
-47.98067 14.48003 -47.62016 14.33066 -47.24423 14.33066 curveto
|
188
|
+
-46.8683 14.33066 -46.5078 14.48003 -46.24199 14.74583 curveto
|
189
|
+
-45.97618 15.01164 -45.82681 15.37215 -45.82681 15.74808 curveto closepath fill
|
190
|
+
0 0.5 dtransform truncate idtransform setlinewidth pop
|
191
|
+
newpath 0 0 moveto
|
192
|
+
0 0 lineto stroke
|
193
|
+
newpath 1.41742 0 moveto
|
194
|
+
1.41742 0.37593 1.26805 0.73643 1.00224 1.00224 curveto
|
195
|
+
0.73643 1.26805 0.37593 1.41742 0 1.41742 curveto
|
196
|
+
-0.37593 1.41742 -0.73643 1.26805 -1.00224 1.00224 curveto
|
197
|
+
-1.26805 0.73643 -1.41742 0.37593 -1.41742 0 curveto
|
198
|
+
-1.41742 -0.37593 -1.26805 -0.73643 -1.00224 -1.00224 curveto
|
199
|
+
-0.73643 -1.26805 -0.37593 -1.41742 0 -1.41742 curveto
|
200
|
+
0.37593 -1.41742 0.73643 -1.26805 1.00224 -1.00224 curveto
|
201
|
+
1.26805 -0.73643 1.41742 -0.37593 1.41742 0 curveto closepath fill
|
202
|
+
0.5 0 dtransform exch truncate exch idtransform pop setlinewidth
|
203
|
+
newpath 47.24423 0 moveto
|
204
|
+
47.24423 15.74808 lineto stroke
|
205
|
+
newpath 48.66165 15.74808 moveto
|
206
|
+
48.66165 16.12401 48.51228 16.48451 48.24648 16.75032 curveto
|
207
|
+
47.98067 17.01613 47.62016 17.1655 47.24423 17.1655 curveto
|
208
|
+
46.8683 17.1655 46.5078 17.01613 46.24199 16.75032 curveto
|
209
|
+
45.97618 16.48451 45.82681 16.12401 45.82681 15.74808 curveto
|
210
|
+
45.82681 15.37215 45.97618 15.01164 46.24199 14.74583 curveto
|
211
|
+
46.5078 14.48003 46.8683 14.33066 47.24423 14.33066 curveto
|
212
|
+
47.62016 14.33066 47.98067 14.48003 48.24648 14.74583 curveto
|
213
|
+
48.51228 15.01164 48.66165 15.37215 48.66165 15.74808 curveto closepath fill
|
214
|
+
newpath 94.48802 0 moveto
|
215
|
+
94.48802 62.99231 lineto stroke
|
216
|
+
newpath 95.90544 62.99231 moveto
|
217
|
+
95.90544 63.36824 95.75607 63.72874 95.49026 63.99455 curveto
|
218
|
+
95.22446 64.26036 94.86395 64.40973 94.48802 64.40973 curveto
|
219
|
+
94.11209 64.40973 93.75159 64.26036 93.48578 63.99455 curveto
|
220
|
+
93.21997 63.72874 93.0706 63.36824 93.0706 62.99231 curveto
|
221
|
+
93.0706 62.61638 93.21997 62.25587 93.48578 61.99007 curveto
|
222
|
+
93.75159 61.72426 94.11209 61.57489 94.48802 61.57489 curveto
|
223
|
+
94.86395 61.57489 95.22446 61.72426 95.49026 61.99007 curveto
|
224
|
+
95.75607 62.25587 95.90544 62.61638 95.90544 62.99231 curveto closepath fill
|
225
|
+
newpath 141.73225 0 moveto
|
226
|
+
141.73225 141.73225 lineto stroke
|
227
|
+
newpath 143.14967 141.73225 moveto
|
228
|
+
143.14967 142.10818 143.0003 142.46869 142.7345 142.7345 curveto
|
229
|
+
142.46869 143.0003 142.10818 143.14967 141.73225 143.14967 curveto
|
230
|
+
141.35632 143.14967 140.99582 143.0003 140.73001 142.7345 curveto
|
231
|
+
140.4642 142.46869 140.31483 142.10818 140.31483 141.73225 curveto
|
232
|
+
140.31483 141.35632 140.4642 140.99582 140.73001 140.73001 curveto
|
233
|
+
140.99582 140.4642 141.35632 140.31483 141.73225 140.31483 curveto
|
234
|
+
142.10818 140.31483 142.46869 140.4642 142.7345 140.73001 curveto
|
235
|
+
143.0003 140.99582 143.14967 141.35632 143.14967 141.73225 curveto closepath
|
236
|
+
fill
|
237
|
+
showpage
|
238
|
+
%%EOF
|
@@ -0,0 +1,75 @@
|
|
1
|
+
prologues := 2;
|
2
|
+
filenametemplate "%j-%c.mps";
|
3
|
+
picture ORIGINAL_PICTURE;
|
4
|
+
ORIGINAL_PICTURE := currentpicture;
|
5
|
+
picture picDblerg;
|
6
|
+
|
7
|
+
%draw the axes
|
8
|
+
draw ((5.6cm,0)--(-5.3cm,0));
|
9
|
+
draw ((0, -0.3cm)--(0, 5.6cm));
|
10
|
+
|
11
|
+
%draw xticks
|
12
|
+
draw ((0,-0.1cm)--(0,0.1cm)) shifted (-5.0cm, 0);
|
13
|
+
label.lrt(btex -3 etex ,(-5.0cm, 0));
|
14
|
+
draw ((0,-0.1cm)--(0,0.1cm)) shifted (-3.33333333333333cm, 0);
|
15
|
+
label.lrt(btex -2 etex ,(-3.33333333333333cm, 0));
|
16
|
+
draw ((0,-0.1cm)--(0,0.1cm)) shifted (-1.66666666666667cm, 0);
|
17
|
+
label.lrt(btex -1 etex ,(-1.66666666666667cm, 0));
|
18
|
+
draw ((0,-0.1cm)--(0,0.1cm)) shifted (0.0cm, 0);
|
19
|
+
label.lrt(btex 0 etex ,(0.0cm, 0));
|
20
|
+
draw ((0,-0.1cm)--(0,0.1cm)) shifted (1.66666666666667cm, 0);
|
21
|
+
label.lrt(btex 1 etex ,(1.66666666666667cm, 0));
|
22
|
+
draw ((0,-0.1cm)--(0,0.1cm)) shifted (3.33333333333333cm, 0);
|
23
|
+
label.lrt(btex 2 etex ,(3.33333333333333cm, 0));
|
24
|
+
draw ((0,-0.1cm)--(0,0.1cm)) shifted (5.0cm, 0);
|
25
|
+
label.lrt(btex 3 etex ,(5.0cm, 0));
|
26
|
+
|
27
|
+
%draw yticks
|
28
|
+
draw ((-0.1.cm,0)--(0.1cm,0)) shifted (0,1.66666666666667cm);
|
29
|
+
label.rt(btex 3 etex ,(0,1.66666666666667cm));
|
30
|
+
draw ((-0.1.cm,0)--(0.1cm,0)) shifted (0,3.33333333333333cm);
|
31
|
+
label.rt(btex 6 etex ,(0,3.33333333333333cm));
|
32
|
+
draw ((-0.1.cm,0)--(0.1cm,0)) shifted (0,5.0cm);
|
33
|
+
label.rt(btex 9 etex ,(0,5.0cm));
|
34
|
+
|
35
|
+
%draw xticks
|
36
|
+
label.top(btex t etex, (5.6cm,0));
|
37
|
+
|
38
|
+
%draw yticks
|
39
|
+
label.rt(btex X(t) etex, (0, 5.6cm));
|
40
|
+
draw ((-5.0cm, 5.0cm)..(-3.33333333333333cm, 2.22222222222222cm)..(-1.66666666666667cm, 0.555555555555556cm)..(0.0cm, 0.0cm)..(1.66666666666667cm, 0.555555555555556cm)..(3.33333333333333cm, 2.22222222222222cm)..(5.0cm, 5.0cm)) withcolor(1.0,0,0);
|
41
|
+
draw ((-5.0cm, 5.0cm)--(-3.33333333333333cm, 2.22222222222222cm)--(-1.66666666666667cm, 0.555555555555556cm)--(0.0cm, 0.0cm)--(1.66666666666667cm, 0.555555555555556cm)--(3.33333333333333cm, 2.22222222222222cm)--(5.0cm, 5.0cm)) withcolor(1.0,0,0);
|
42
|
+
drawarrow (-5.0cm, 0)--(-5.0cm, 5.0cm) withcolor(0,1.0,0);
|
43
|
+
drawarrow (-3.33333333333333cm, 0)--(-3.33333333333333cm, 2.22222222222222cm) withcolor(0,1.0,0);
|
44
|
+
drawarrow (-1.66666666666667cm, 0)--(-1.66666666666667cm, 0.555555555555556cm) withcolor(0,1.0,0);
|
45
|
+
drawarrow (0.0cm, 0)--(0.0cm, 0.0cm) withcolor(0,1.0,0);
|
46
|
+
drawarrow (1.66666666666667cm, 0)--(1.66666666666667cm, 0.555555555555556cm) withcolor(0,1.0,0);
|
47
|
+
drawarrow (3.33333333333333cm, 0)--(3.33333333333333cm, 2.22222222222222cm) withcolor(0,1.0,0);
|
48
|
+
drawarrow (5.0cm, 0)--(5.0cm, 5.0cm) withcolor(0,1.0,0);
|
49
|
+
draw (-5.0cm, 0)--(-5.0cm, 5.0cm) withcolor(0,0,1.0);
|
50
|
+
fill fullcircle scaled (0.1cm) shifted (-5.0cm, 5.0cm) withcolor(0,0,1.0);
|
51
|
+
draw (-3.33333333333333cm, 0)--(-3.33333333333333cm, 2.22222222222222cm) withcolor(0,0,1.0);
|
52
|
+
fill fullcircle scaled (0.1cm) shifted (-3.33333333333333cm, 2.22222222222222cm) withcolor(0,0,1.0);
|
53
|
+
draw (-1.66666666666667cm, 0)--(-1.66666666666667cm, 0.555555555555556cm) withcolor(0,0,1.0);
|
54
|
+
fill fullcircle scaled (0.1cm) shifted (-1.66666666666667cm, 0.555555555555556cm) withcolor(0,0,1.0);
|
55
|
+
draw (0.0cm, 0)--(0.0cm, 0.0cm) withcolor(0,0,1.0);
|
56
|
+
fill fullcircle scaled (0.1cm) shifted (0.0cm, 0.0cm) withcolor(0,0,1.0);
|
57
|
+
draw (1.66666666666667cm, 0)--(1.66666666666667cm, 0.555555555555556cm) withcolor(0,0,1.0);
|
58
|
+
fill fullcircle scaled (0.1cm) shifted (1.66666666666667cm, 0.555555555555556cm) withcolor(0,0,1.0);
|
59
|
+
draw (3.33333333333333cm, 0)--(3.33333333333333cm, 2.22222222222222cm) withcolor(0,0,1.0);
|
60
|
+
fill fullcircle scaled (0.1cm) shifted (3.33333333333333cm, 2.22222222222222cm) withcolor(0,0,1.0);
|
61
|
+
draw (5.0cm, 0)--(5.0cm, 5.0cm) withcolor(0,0,1.0);
|
62
|
+
fill fullcircle scaled (0.1cm) shifted (5.0cm, 5.0cm) withcolor(0,0,1.0);
|
63
|
+
picDblerg := currentpicture; currentpicture := ORIGINAL_PICTURE;
|
64
|
+
|
65
|
+
beginfig(1);
|
66
|
+
draw ((-3cm, 9cm)..(-2cm, 4cm)..(-1cm, 1cm)..(0cm, 0cm)..(1cm, 1cm)..(2cm, 4cm)..(3cm, 9cm)) withcolor(1.0,0,0);
|
67
|
+
|
68
|
+
endfig;
|
69
|
+
|
70
|
+
beginfig(2);
|
71
|
+
draw picDblerg ;
|
72
|
+
|
73
|
+
endfig;
|
74
|
+
|
75
|
+
end;
|