0

Since I have to use an old version of gnuplot 4.0, I found that the circle style is not available. Can any one suggest me how to draw circle with different size from data like this:

   x             y       size
0.000000    -18.595474   2.752
0.154186    -18.574680   0.752
0.308371    -18.513723   0.752
0.462557    -18.416941   3.753
0.616743    -18.291512   1.754
0.770928    -18.147374   2.755
0.925114    -17.996800   2.757
1.079300    -17.853565   0.759
1.233485    -17.731370   4.761
1.387671    -17.642539   0.763
1.541857    -17.605154   1.763

I use a command like this but it told me an error that undefined variable: variable

plot "data0" u 1:2:3 with points pt 7 lt 1 ps variable title 'total'

Thank you so much!

Binh Thien
  • 363
  • 2
  • 13

1 Answers1

1

Ouch, I would say this is not straightforward. This feature (using variable pointsize from data) and a lot of other useful features (loops, expressions in plot command, arrays, etc. ) to create an "easy" workaround were introduced in later versions of gnuplot.

In gnuplot 5.2.6, this would simply be

plot 'Data.dat' u 1:2:3 w p ps var

However, for gnuplot 4.0, you can create a strange workaround with

  1. a fixed x-y-range
  2. multiplot
  3. reread a subroutine
  4. fitting data to get the value of the third column into a variable (pretty weird)
  5. if you also want the last data point you have to add some dummy data line at the end

Tested with gnuplot 4.0 on Win 7 with a windows terminal. Maybe I overlooked a simpler way, but with gnuplot 4.0 you are pretty limited. You must have a good reason that you don't want or cannot update to newer versions.

Data: tbCirclesV4.dat

#   x             y       size
0.000000    -18.595474   2.752
0.154186    -18.574680   0.752
0.308371    -18.513723   0.752
0.462557    -18.416941   3.753
0.616743    -18.291512   1.754
0.770928    -18.147374   2.755
0.925114    -17.996800   2.757
1.079300    -17.853565   0.759
1.233485    -17.731370   4.761
1.387671    -17.642539   0.763
1.541857    -17.605154   1.763
0.000000      0.000000   0.000

Main program: tbCirclesV4.plt

### mimic "plot 1:2:3 w p ps var" in gnuplot V4.0
reset
set term windows

set multiplot
    set xrange[-0.1:1.6]
    set yrange[-19:-17]
    i=0
    Max=11
    f(x) = a*x + b
    load 'tbCirclesV4Loop.plt'
unset multiplot
### end of code

Sub-Routine: tbCirclesV4Loop.plt

### sub-routine
a=1
b=1
fit [*:*][*:*] f(x) 'tbCirclesV4.dat' every ::i::i+1 u 0:3 via a,b
print "Size: ", i, b

# use pointsize b*2 to enlarge the circles a little
plot 'tbCirclesV4.dat' u 1:2 every ::i::i w lp pt 8 ps b*2 lt i+1 notitle
i=i+1

if (i<Max) reread
### end of sub-routine

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72
  • Thank you so much for your suggestion! I tried it and it took a bit long time since my data file is large. – Binh Thien Sep 30 '19 at 06:20
  • Glad that is seems be an acceptable solution for you. If you have >1000 points you will have >1000 borders on top of each other. If your output is .eps the file probably will be also pretty large. This can certainly be optimized. For bitmap outputs this wouldn't be an issue. I would be curious about the reason you can't switch to newer version. – theozh Sep 30 '19 at 06:47
  • @BinhThien so, if this answered your question, then please mark it as helpful/solved. – theozh May 11 '21 at 04:18