Plotting from an analytic function expression

Plot in cartesian coordinate system

In [1]:
require 'gnuplotrb'
include GnuplotRB

cartesian = Plot.new(
  ['x*sin(x)', with: 'lines', lt: { rgb: 'blue', lw: 3 }],
  xrange: -10..10,
  title: 'Math function example', 
  ylabel: 'x',
  xlabel: 'x*sin(x)'
)
Out[1]:
Gnuplot Produced by GNUPLOT 5.0 patchlevel rc2 -6 -4 -2 0 2 4 6 8 -10 -5 0 5 10 x x*sin(x) Math function example x*sin(x) x*sin(x)

Plot in polar coordinate system

In [2]:
Plot.new(
  ['abs(sin(3*t))', with: 'filledcurves', lt: { rgb: 'red' }],
  title: 'Plot in polar example',
  polar: true,
  samples: 500
)
Out[2]:
Gnuplot Produced by GNUPLOT 5.0 patchlevel rc2 1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1 1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 Plot in polar example abs(sin(3*t)) abs(sin(3*t))

Plot from a parametric function expression

In [3]:
Plot.new(
  ['1.5*cos(t) - cos(30*t), 1.5*sin(t) - sin(30*t)', title: 'Parametric curve', lw: 2],
  title: 'Parametric plot example',
  parametric: true,
  samples: 1000,
  xrange: -3..3,
  yrange: -3..3
)
Out[3]:
Gnuplot Produced by GNUPLOT 5.0 patchlevel rc2 -3 -2 -1 0 1 2 3 -3 -2 -1 0 1 2 3 Parametric plot example Parametric curve Parametric curve