Search code examples
gnuplotgnuplot-iostream

gnuplot not showing correct scale on y axis for a circle


I am modelling a graph problem using gnuplot

I am plotting a circle with gnuplot using the following command

set xtics 1
set ytics 1
plot 'circles.txt' with circle

my circles.txt contains the follwoing data

0 0 3

enter image description here

the upmost point on this circle(center at origin and radius of 3 ) should be (0,3) but it is shown as (0,2) in this graph

how can i rectify this error?


Solution

  • Plotting with circles is intended for plotting the points as circles so they would be round regardless of axes scaling. As it is pointed in gnuplot documentation,

    The radius is always interpreted in the units of the plot's horizontal axis (x or x2). The scale on y and the aspect ratio of the plot are both ignored.

    You can plot with ellipses instead; from documentation on plot with ellipses:

      2 columns: x y
      3 columns: x y major_diam
      4 columns: x y major_diam minor_diam
      5 columns: x y major_diam minor_diam angle
    

    so you plot this as

    plot 'circles.txt' using 1:2:($3*2):($3*2) with ellipses
    

    (ellipses use diameter, so the size should be the third column twice)

    Or set object ellipse:

     set object ellipse at 0, 0 size 6, 6