18

I know on gnuplot you can plot some data with circles as the plot points:

plot 'data.txt' using 1:2 ls 1 with circles

How do I then set the size of the circles? I want to plot several sets of data but with different size circles for each data set.

user1118321
  • 25,567
  • 4
  • 55
  • 86
Eddy
  • 6,661
  • 21
  • 58
  • 71

2 Answers2

12

If you have a third column in your data, the third column specifies the size of the circles. In your case, you could have the third column have the same value for all the points in each data set. For example:

plot '-' with circles
1 1 0.2
e

will plot a circle at (1,1) with radius 0.2. Note that the radius is in the same units as the data. (The special file name '-' lets you input data directly; typing 'e' ends the input. Type help special at the gnuplot console for more info.)

You can look here for more ideas of how to use circles.

andyras
  • 15,542
  • 6
  • 55
  • 77
  • Fancy -- I didn't know this one off the top of my head. I guess I haven't plotted with circles before. I that a 4.3+ feature? I always resorted to plotting `with points pointsize variable` (Yuck!). (+1). – mgilson Aug 01 '12 at 02:03
  • My program produces data in 2 columns. I want just a constant size to the circles for each data set. Does that mean I need to add a 3rd column of identical numbers to my dataset? Is there not another way? – Eddy Aug 01 '12 at 08:49
  • 5
    @Eddy -- you can do something like `plot 'datafile' u 1:2:(1.5) w circles`. This will make circles with a radius of 1.5 (and you only need 2 columns of data in the datafile). How are your datasets separated in the file? If they're separated by 2 blank lines, you can use pseudo-column -2 to pick out the index number. – mgilson Aug 01 '12 at 12:27
  • @mgilson I couldn't get it to work. I don't get a circle at each x,y coordinate, but instead get a load of circles stacked on top of each other and the x-axis ranges from -1.5 to 1.5. My data is just 2 columns, separated by a space. – Eddy Aug 02 '12 at 21:40
  • 2
    @Eddy: Are your data values very small? mgilson's value of 1.5 for the radius was just an example; you should scale it such that the circles will be a reasonable size. If your data values are, for example, on the order of 0.01, the radius of your circles should be something like 0.001 or 0.0001. – andyras Aug 03 '12 at 00:38
  • @andyras: Thanks, yes my data values were on the order of 10^(-9) so I needed to scale the radius of my circles appropiately. – Eddy Aug 06 '12 at 13:09
  • A few words about the `plot '-'` feature could help to figure out what is going on here: a "data input console" is opened... – Wolf Nov 24 '15 at 14:23
  • 2
    One caveat: plot marker circles will match the X scale of your plot and ignore the Y scale of your plot. So if you want to illustrate precise geometry, you need 'set size ratio -1' – Erik Olson Mar 07 '16 at 16:13
8

I used:

plot "file" using 1:2:($2*0+10) with circles

This will fake a the third column specifying the sizes - it is probably possible to write it simpler, but this worked for me.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Ketil Malde
  • 311
  • 3
  • 6