A polar plot places each point by angle and distance from the center instead of by x and y, which is the natural way to draw periodic patterns, antenna patterns, and rose curves.
set polar
set trange [0:2*pi]
set size square
set title "Polar Plot: r = sin(3t)"
unset key
plot sin(3*t) with lines linewidth 2 linecolor rgb "#5e2d79"
How the script works
set polar switches gnuplot into polar mode: the plotted function now returns a radius r for each angle, and the independent variable is named t instead of x.
set trange [0:2*pi] sets the angle sweep to one full turn, from 0 to 2π radians. The rose sin(3*t) completes its pattern exactly in that sweep: the factor 3 gives the curve its three petals, because the radius rises and falls three times per revolution. Negative radius values are plotted by pointing the point in the opposite direction, which is what closes the petal shapes.
set size square keeps one unit of angle-distance the same length horizontally and vertically, so the rose is not stretched into an ellipse. unset key removes the legend, which adds nothing for a single curve.
Run it online: Paste this script into the online terminal and run it — no install needed.
Variant to try
Change the petal count by changing the factor: plot sin(5*t) draws five petals, and plot 1 + sin(t) draws a cardioid-like single loop offset from the center. For measured polar data from a file with angle and radius columns, the same mode applies: keep set polar and plot the file with using 1:2 with linespoints, where column 1 is read as the angle.
Related tutorials: Your First Gnuplot Plot, Line Styles, Colors and Point Types. See more copy-and-run scripts in the Gnuplot Examples index.
Scripts on this page are adapted from the official gnuplot 6.0 demo collection (gnuplot.info) and rewritten for this tutorial.
