I browsed through the gallery of animated example under pgf but didn't find my answer.

I would like this kind of pictures: take 4 points located at (0,0), (1,0), (5,0) and (7,0); for r varying from 0 to 2 by step 0.2, draw a circle of radius r cm around each of these points (a frame corresponds to a value of r); below the circles, draw four lines, the first ends at r=0.5, the second ends at r=1, i.e \draw (0,-3) -- (min(r,1), -3);

I'm stuck with the computation of the minimum since I don't know what kind of variable should be r (a counter, a sort of argument) and with the varying sizes of the circle because I don't know how to indicate the unit.

Any help would be appreciated.

  • Welcome to TeX.SX! Please add a MWE to see what you did so far.
    – osjerick
    Oct 13 '15 at 12:52
  • There are two parts actually. First is to draw the picture and second is to animate it. So two big questions without any code duh!.
    – user11232
    Oct 13 '15 at 13:03
  • And how should be those four lines drawn? " draw four lines, the first ends at r=0.5 the second ends at r=1 i.e \draw (0,-3) -- (min(r,1), -3); " is not clear. For minimum you can use \pgfmathmin{x1}{x2}\pgfmathresult
    – user11232
    Oct 13 '15 at 13:23

The description of the problem, particualrly of the segments that should be drawn is not clear, but you can adapt my example to suit your needs:


  visible on/.style={alt={#1{}{invisible}}},
  alt/.code args={<#1>#2#3}{%


\foreach \Value in {0,1,5,7}
\node[circle,fill,inner sep=2pt] at (\Value cm,0) {};
\foreach \Radius [count=\xi] in {0,0.2,...,2}
  \draw[visible on=<\xi>] (\Value,0) circle (\Radius cm);
  \draw[visible on=<\xi>] (\Value,-3cm) -- ++({min(\Radius,1)},0pt);  


The resulting animation:

enter image description here

If you are not using beamer, you can still use my code and produce the animation with the animate package.

  • OK done. May I ask what the code invisible/visible is for ?
    – Laurent D.
    Oct 15 '15 at 14:33
  • @LaurentD. Thanks. That code prevents the elements from jumping. The drawing for all elements is performed on all slides, but with visible on you can control on which slides you want an element to be visible. Oct 15 '15 at 14:58

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.