LoginSignup
0
0

More than 3 years have passed since last update.

IRubyのPlotyでグラフを並べる

Last updated at Posted at 2019-06-18

image.png
JupyterLab で IRuby と iruby-plotly を使うというアホほどマイナーな使用事例に関するメモです。
https://github.com/zach-capalbo/iruby-plotly
(2019年6月18日現在 Github Star が1つしかない)

gridを指定すればグラフを並べられる。
注意点は、それぞれのグラフについて別々のxaxis、yaxisを指定するところ。これをやらないと、plotly先生はよかれと思ってグラフをまとめてしまう。なおかつ、x0, y0だと正常に動かないみたい。なんでだろ

rquire 'iruby/plotly'

data = Array.new(10){ |i|
{
  x: [*1..100],
  y: Array.new(100){rand(10)},
  xaxis: "x#{i+1}",
  yaxis: "y#{i+1}",
  type: 'bar',
}}

layout = {
  grid: {rows: 10, columns: 1, pattern: 'independent'},
    height: 800
}

IRuby.plotly(data, layout)

image.png

こうすれば

data = Array.new(16){ |i|
{
  x: [*1..20],
  y: Array.new(20){rand(10)},
  xaxis: "x#{i+1}",
  yaxis: "y#{i+1}",
  type: 'bar',
}}

layout = {
  grid: {rows: 4, columns: 4, pattern: 'independent'},
    height: 800
}

IRuby.plotly(data, layout);

こうなる。

image.png

typeが line なら

image.png

grid 2, 8なら

image.png

べんり過ぎる。

便利すぎるけど導入めんどうくさいし、知名度低いから誰も使わないんだろうな…

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0