require "rubygems"
gem "nyaplot", "0.2.0.rc1"
true
$DEBUG_NYAPLOT = true
true
require 'nyaplot'
include Nyaplot
Object
p1 = Plot.add(:scatter, x: [1,2,3], y: [3,-2, 4])
samples = Array.new(10).map.with_index{|d,i| 'cat'+i.to_s}
x=[];y=[];home=[]
10.times do
x.push(5*rand)
y.push(5*rand)
end
df = Nyaplot::DataFrame.new({x:x,y:y,name:samples})
df
x | y | name | |
---|---|---|---|
0 | 4.048423819410348 | 4.210927404984771 | cat0 |
1 | 2.3983872966413644 | 0.9947338599167022 | cat1 |
2 | 4.187615173655737 | 2.433216846323116 | cat2 |
3 | 4.679018887070961 | 1.215626671171648 | cat3 |
4 | 1.287643275820594 | 2.5304140551803034 | cat4 |
5 | 4.190044663795205 | 4.391207230642776 | cat5 |
6 | 1.0612547264323418 | 1.8479149433242141 | cat6 |
7 | 0.6142547369879214 | 2.924421530548822 | cat7 |
8 | 2.524377598742607 | 2.338777618229196 | cat8 |
9 | 3.579432082687719 | 1.61809260676625 | cat9 |
p2 = Plot.from(df).add(:scatter, x: :x, y: :y).shape_by(:name)
p3 = Plot.from(df).add(:line, x: :x, y: :y).width(1000)
rows(columns(p1, p2), p3)