I'm trying to reconstruct this picture in MetaPost:

enter image description here

So far came up with this:

draw (-1cm,0)--(3cm,0);
draw (0,1cm)--(0,-1cm);
draw fullcircle scaled 1.8cm;
label(btex $y$ etex,(0,1.2cm));
label(btex $x$ etex,(3.2cm,0));
label(btex \textsf{SVEU\v CILI\v STE U RIJECI} etex,(1cm,1.7cm));
label(btex \textsf{ODJEL ZA MATEMATIKU} etex,(1cm,-1.5cm));

Obviously, the sine graph is missing. I tried a few ways, but I couldn't even get it to compile. Can anyone provide some assistance?


Try the following:

draw (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor;
| improve this answer | |
  • 2
    +1 for answering the question, using metapost (not Tikz), and not using fancy LaTeX dialects (i.e., you avoided LuaLaTeX). – Alex Nelson Dec 23 '12 at 20:17

I know that you said metapost, so I'll probably get voted down for this answer! (In my defence, I suspect that more people are going to be interested in how to draw a sine wave by any means than specifically by metapost, so although this doesn't answer your specific question, it's hopefully close enough to be worth leaving nearby). This is really easy in TikZ: p124 of the manual:

\draw (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0) sin (5,1);

draws a sine wave.

More generally, TikZ can interact nicely with gnuplot to draw graphs of functions (see the manual for details). Gnuplot does the computation, TikZ does the rendering.

| improve this answer | |

run it with lualatex which makes the use of MP easier:


\large\textsf{SVEU\v CILI\v STE U RIJECI}

def compute_curve(suffix f)(expr xmin,xmax,xinc) = ( (xmin,f(xmin))
    for x=xmin+xinc step xinc until xmax: ..(x,f(x)) endfor )
vardef f(expr x)=sind(x*180/3.14) enddef;
path g;
draw g xscaled 8pt yscaled 0.9cm withpen pencircle scaled 2bp;
draw (-1cm,0)--(3cm,0);
draw (0,1cm)--(0,-1cm);
draw fullcircle scaled 1.8cm;


enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.