numo-gnuplot sample

qiita.com

ウィンドウで表示する場合。Linux Mint 20.3。

require "numo/gnuplot"

Numo.gnuplot do
  set terminal: "wxt font 'Noto Sans CJK JP,12'"
  set title: "グラフのタイトル"
  set xrange: 0..6
  set yrange: 0..60
  set xlabel: "x軸のラベル"
  set ylabel: "y軸のラベル"
  
  x = [1, 2, 3]
  y1 = [11, 25, 32]
  y2 = [21, 35, 42]
  y3 = [31, 45, 52]
  
  plot x, y1, {title: "系列1"},
       x, y2, {w: :lines, title: "系列2(線のみ)"},
       x, y3, {w: :linespoints, title: "系3(点と線)"},
       "x * 10", {title: "y = x * 10"}
end

sleep

20220529181731