I have a file with 3 columns, space separated. The first two columns represent the center of a circle (x,y) and the last column is the circle radius.

I want to select every 4 rows (or more generally specifying row numbers in a list) and plot selected circles by a for loop.

I do not seem to work it out in pgfplotstable. Any hints?!


  • 1
    Can you show the code you have so far? – Jake Jul 8 '13 at 11:09
  • I am reading pgfplotstable manual; I do not know how to pick up a row number and get its columns. If I have that I put \pgfplotstableread{data}\mydata; foreach i \in{1,4,8}{ get row i; \draw (axis cs:i1,i2) circle [radius=i3];} – eli Jul 8 '13 at 11:20

Here's a slightly adapted version of my answer to Drawing different tikz shapes parameterized by data from a file. It draws the circles using a scatterplots. You can choose to draw only every n-th mark using the mark repeat key, choosing which entry to start with using the mark phase key.


\usepackage{pgfplots, filecontents}

# x y r
1 1 1
3 2 0.5
6 3 0.4
4 1 0.8
5 4 0.3
6 2 1

    scatter src=explicit,
    axis equal,
    only marks,
    xmin=0, xmax=8,
    scatter/@pre marker code/.code={% Transform the data units to paper units
      \scope[mark size=\pgfmathresult]
\addplot [fill=yellow, mark repeat=2] file {data.dat};

  • oh! somehow those keys you used after xmax, do the trick; 'cause I do not see any circle command ! mark repeat is much better than x filter, Many thanks ! – eli Jul 8 '13 at 11:54
  • The circles are drawn because the default plot marks in the axis environment are circles. You can change what shape to draw by setting mark=square* in the \addplot options, for example. The circles are selected using mark=*. – Jake Jul 8 '13 at 12:18

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.