forked from ievgrafov/gnuplotrb
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathplot.rb
More file actions
28 lines (26 loc) · 779 Bytes
/
plot.rb
File metadata and controls
28 lines (26 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'gnuplotrb'
include GnuplotRB
titles = %w{decade Austria Hungary Belgium}
data = [
['1891-1900', 234081, 181288, 18167],
['1901-1910', 668209, 808511, 41635],
['1911-1920', 453649, 442693, 33746],
['1921-1930', 32868, 30680, 15846],
['1931-1940', 3563, 7861, 4817],
['1941-1950', 24860, 3469, 12189],
['1951-1960', 67106, 36637, 18575],
['1961-1970', 20621, 5401, 9192],
]
x = data.map(&:first)
plots = (1..3).map do |col|
y = data.map { |row| row[col] }
Plot.new([[x, y], using: '2:xtic(1)', title: titles[col]])
end
mp = Multiplot.new(
*plots,
layout: [plots.size, 1],
style_data: 'histograms',
title: 'Histograms',
xtics: 'nomirror rotate by -45'
)
mp.to_png('./gnuplot_gem.png', size: [400,800])