-1

I know the command to plot circle in gnuplot:

plot 'circle.txt' using 1:2:3 with circles

Suppose if circle.txt contains n lines and each line contains (centerX, centerY, radius) of different circles, e.g.:

#x  y   radius
0   0   1
1   1   2
2   2   3

How can I generate n images containing n different circles - one image per line?

Schorsch
  • 7,761
  • 6
  • 39
  • 65
user69910
  • 971
  • 2
  • 9
  • 14

1 Answers1

2

This will work with gnuplot 4.4 and higher:

gnuplot> n = "`awk 'END {print NR}' < circle.txt`"
gnuplot> i=0; while i<n{set term wxt i; plot 'circle.txt' every ::i::i using 1:2:3 with circles; i=i+1}

Explanation:

  • "`awk 'END {print NR}' < circle.txt`" to determine the number of rows in the file
    (Warning: This does not work on a Windows 32-bit system)
  • i=0 to set the counter for the while loop
  • while i<n loop through the rows of the file
  • { } while-clause has to be in curly braces
  • set term wxt i this portion opens the new window for each plot
  • separate commands by ;
  • plot 'circle.txt' every ::i::i using 1:2:3 with circles this plots just the ith line of the file. More information on plotting specific lines can be found here.
  • i=i+1 increment the counter
Schorsch
  • 7,761
  • 6
  • 39
  • 65
  • @user69910 Please consider accepting the answer by clicking the checkmark (✓) next to the voting buttons or commenting on what does not work for you. – Schorsch Jul 03 '13 at 16:36