Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/extras/Region.m4

raw
1 .PS
2 # Region.m4
3 # https://tex.stackexchange.com/questions/606088/how-can-i-plot-in-latex
4 gen_init
5
6 grsize = 3.3
7 maxaxis = 4.5
8 define Grid { (($1+maxaxis)/(2*maxaxis)*grsize-grsize/2,\
9 ($2+maxaxis)/(2*maxaxis)*grsize-grsize/2) }
10
11 thinlines_
12 box wid grsize ht grsize with .c at (0,0)
13 tic = 0.05
14 for x=-maxaxis to maxaxis by 0.5 do {
15 line up tic from Grid(x,-maxaxis)
16 y = abs(x)
17 { if y/2 == int(y/2+0.5) then { sprintf("%g",x) at last line.start below } }
18 line down tic from Grid(x,maxaxis)
19 line right tic from Grid(-maxaxis,x)
20 { if y/2 == int(y/2+0.5) then { sprintf("%g",x) at last line.start rjust } }
21 line left tic from Grid(maxaxis,x)
22 }
23 thicklines_
24
25 n = 10
26 ylim = 3
27 for i=0 to n do { y = i/n*ylim
28 P[i]: Grid(sqrt(1+y^2),y)
29 P[-i]:( P[i].x,-P[i].y)
30 Q[i]: (-P[i].x, P[i].y)
31 Q[-i]:(-P[i].x,-P[i].y) }
32 rgbfill(0.6,0.6,0.8,
33 fitcurve(P,n,,-n)
34 line to (P[n].x,P[n].x) then to (Q[-n].x,Q[-n].x) then to Q[-n]
35 fitcurve(Q,n,,-n)
36 line to (Q[n].x,-Q[n].x) then to (P[-n].x,-P[-n].x) then to P[-n] )
37
38 .PE