Skip to content

Instantly share code, notes, and snippets.

@domitry
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domitry/9656463 to your computer and use it in GitHub Desktop.
Save domitry/9656463 to your computer and use it in GitHub Desktop.
Sample of the new Plotrb, GSoC2014
models = [{"attributes":
{"data_source":{"type":"ColumnDataSource","id":"3c6d2ed9-dcfc-4b9f-8d9b-0c26a0272ccc"}
"doc":null,
"id":"3c6d2ed9-dcfc-4b9f-8d9b-0c26a0272ccc"
}.
"type":"Glyph",
"id":"3c6d2ed9-dcfc-4b9f-8d9b-0c26a0272ccc"
},
{"attributes":
{"column_names":["fill_color","line_color","shape","x","y"],
"data":
{"x":["18.2","11.3","10.5",......,"5.4","12.3","11.9"],
"y":["18.2","11.3","10.5",......,"5.4","12.3","11.9"],
"fill_color":["red","red","red",..........."red","red"],
"line_color":["red","red","red",..........."red","red"],
"shape":["circle","cross","cross",........"diamond"]
}
"type":"ColumnDataSource",
"id":"3c6d2ed9-dcfc-4b9f-8d9b-0c26a0272ccc"
},
{"attributes":
{"x_axis":
................
}
}]
setTimeout(function(){
embed_core =Plotrbjs.embed_core;
embed_core.plot(models);},20)
require ‘plotrb’
N =21
raw_data =[]
shapes = [“circle”, “cross”, “triangle”]
3.times do |i|
arr_x =Array.new(N){Random.rand(19.9)}
arr_y =Array.new(N){Random.rand(19.9)}
arr_shape = Array.new(N){shapes.sample}
raw_data.push({name:"Group"+ i.to_str, x: arr_x, y: arr_y, shape: arr_shape})
end
scatter =Scatter.new do
raw_data.each{|group| add_data(group)}
axis_titles(x:"Index", y:"Data Value")
legend(title:"Categories")
enable :tooltip, :interactive
end
scatter.display()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment