Gnuplot have special layout for placing multiple plots on single layout and GnuplotRB supports this feature as well.
require 'gnuplotrb' include GnuplotRB sinx = Plot.new('sin(x)', title: 'Sin') exp = Plot.new('exp(x)', title: 'Exp') log = Plot.new('log(x)', title: 'Log') sphere = Splot.new( ['sin(u)*cos(v), sin(u)*sin(v), cos(u)', title: 'Sphere'], parametric: true, urange: 0..Math::PI, vrange: 0..2*Math::PI, title: 'sphere', hidden3d: true, isosamples: 30 ) nil
To use this feature in GnuplotRB you just need to pass several Plot or Splot objects to constructor of Multiplot class. It's recommended to give him layout size too.
rows, cols = 2, 2 basic_four = Multiplot.new(sinx, exp, log, sphere, layout: [rows, cols])
You can also set one title for the whole layout.
You can change layout size anytime (if it will have less cells than you have plots, they will be overriden by each other).
basic_two = Multiplot.new(sinx, sphere, layout: [1,2])