Search code examples
gnuplotangleellipse

Gnuplot stretched ellipse by angle option


I want to draw an ellipse with gnuplot. It should be slightly tilted, hence I use the angle option. But the angle messes with the size of the ellipse. Am I getting something wrong in the docu?

See the following example:

set output "test.pdf"
set obj ellipse center 5,0.5 size 4,0.2 angle 20
set xrange [0:10]
plot sin(x)

The added two png's show my results. I use version 5.2.8. No angle With angle


Solution

  • If you want the proportions of the ellipse to remain constant after rotation you must give the major and minor diameters in the same units, e.g. "units xx" or "units yy". Here I define the ellipse in terms of a 4:1 ratio of major:minor axis using x coordinates.

    set obj 1 ellipse center 5,0.5 size 4,1 fs empty bo lc "blue"  angle 0   units xx
    set obj 2 ellipse center 5,0.5 size 4,1 fs empty bo lc "red"   angle 20  units xx
    set obj 3 ellipse center 5,0.5 size 4,1 fs empty bo lc "green" angle 40  units xx
    set xrange [0:10]
    plot sin(x)
    

    enter image description here