simple functions

Original Demo


In [1]:
require "numo/gnuplot"


Out[1]:
true

In [2]:
# # Requires data files "[123].dat" from this directory,
# # so change current working directory to this directory before running.
# # gnuplot> set term <term-type>
# # gnuplot> load 'simple.dem'
# #
# set key left box
# set samples 50
# plot [-10:10] sin(x),atan(x),cos(atan(x))

Numo::Gnuplot::NotePlot.new do
  set :key, :left, :box
  set samples:50
  plot  -10..10,
    "sin(x)",
    "atan(x)",
    "cos(atan(x))"
end


Out[2]:
Gnuplot Produced by GNUPLOT 4.6 patchlevel 6 -1.5 -1 -0.5 0 0.5 1 1.5 -10 -5 0 5 10 gnuplot_plot_1 sin(x) gnuplot_plot_2 atan(x) gnuplot_plot_3 cos(atan(x))

In [3]:
# set key right nobox
# set samples 100
# plot [-pi/2:pi] cos(x),-(sin(x) > sin(x+1) ? sin(x) : sin(x+1))

Numo::Gnuplot::NotePlot.new do
  set :key, :right, :nobox
  set samples:100
  plot "[-pi/2:pi]",
    "cos(x)",
    "-(sin(x) > sin(x+1) ? sin(x) : sin(x+1))"
end


Out[3]:
Gnuplot Produced by GNUPLOT 4.6 patchlevel 6 -1 -0.5 0 0.5 1 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 gnuplot_plot_1 cos(x) gnuplot_plot_2 -(sin(x) > sin(x+1) ? sin(x) : sin(x+1))

In [4]:
# set key left box
# set samples 200
# plot [-3:5] asin(x),acos(x)

Numo::Gnuplot::NotePlot.new do
  set :key, :left, :box
  set samples:200
  plot  -3..5,
    "asin(x)",
    "acos(x)"
end


Out[4]:
Gnuplot Produced by GNUPLOT 4.6 patchlevel 6 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 -3 -2 -1 0 1 2 3 4 5 gnuplot_plot_1 asin(x) gnuplot_plot_2 acos(x)

In [5]:
# plot [-30:20] besj0(x)*0.12e1 with impulses, (x**besj0(x))-2.5 with points

Numo::Gnuplot::NotePlot.new do
  plot  -30..20,
    ["besj0(x)*0.12e1", with:"impulses"],
    ["(x**besj0(x))-2.5", with:"points"]
end


Out[5]:
Gnuplot Produced by GNUPLOT 4.6 patchlevel 6 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 -30 -20 -10 0 10 20 gnuplot_plot_1 besj0(x)*0.12e1 gnuplot_plot_2 (x**besj0(x))-2.5

In [6]:
# set samples 400
# plot [-10:10] real(sin(x)**besj0(x))

Numo::Gnuplot::NotePlot.new do
  set samples:400
  plot  -10..10,
    "real(sin(x)**besj0(x))"
end


Out[6]:
Gnuplot Produced by GNUPLOT 4.6 patchlevel 6 -1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 -10 -5 0 5 10 gnuplot_plot_1 real(sin(x)**besj0(x))

In [7]:
# set key bmargin center horizontal
# plot [-5*pi:5*pi] [-5:5] real(tan(x)/atan(x)), 1/x

Numo::Gnuplot::NotePlot.new do
  set :key, :bmargin, :center, :horizontal
  plot "[-5*pi:5*pi]", -5..5,
    "real(tan(x)/atan(x))",
    "1/x"
end


Out[7]:
Gnuplot Produced by GNUPLOT 4.6 patchlevel 6 -4 -2 0 2 4 -15 -10 -5 0 5 10 15 gnuplot_plot_1 real(tan(x)/atan(x)) gnuplot_plot_2 1/x

In [8]:
# set key left box
# set autoscale
# set samples 800
# plot [-30:20] sin(x*20)*atan(x)

Numo::Gnuplot::NotePlot.new do
  set :key, :left, :box
  set :autoscale
  set samples:800
  plot  -30..20,
    "sin(x*20)*atan(x)"
end


Out[8]:
Gnuplot Produced by GNUPLOT 4.6 patchlevel 6 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -30 -20 -10 0 10 20 gnuplot_plot_1 sin(x*20)*atan(x)

In [9]:
# plot [-19:19] '1.dat' with impulses, '2.dat', '3.dat' with lines

Numo::Gnuplot::NotePlot.new do
  plot  -19..19,
    ["'../gnuplot/script/1.dat'", with:"impulses"],
    "'../gnuplot/script/2.dat'",
    ["'../gnuplot/script/3.dat'", with:"lines"]
end


Out[9]:
Gnuplot Produced by GNUPLOT 4.6 patchlevel 6 -10 -8 -6 -4 -2 0 2 4 6 8 10 -15 -10 -5 0 5 10 15 gnuplot_plot_1 '../gnuplot/script/1.dat' gnuplot_plot_2 '../gnuplot/script/2.dat' gnuplot_plot_3 '../gnuplot/script/3.dat'