{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions.\n",
"\n",
"Install the mechanize gem version ~>2.7.5 for using mechanize functions.\n"
]
},
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"require 'daru/view'"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" Daru::DataFrame(6x3) \n",
"
\n",
" \n",
" \n",
" \n",
" | \n",
" \n",
" a | \n",
" \n",
" b | \n",
" \n",
" c | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
" \n",
" \n",
" a | \n",
" \n",
" 1 | \n",
" \n",
" 1 | \n",
" \n",
" 1 | \n",
" \n",
"
\n",
" \n",
" \n",
" b | \n",
" \n",
" 2 | \n",
" \n",
" 5 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" c | \n",
" \n",
" 3 | \n",
" \n",
" 2 | \n",
" \n",
" 7 | \n",
" \n",
"
\n",
" \n",
" \n",
" d | \n",
" \n",
" 4 | \n",
" \n",
" 5 | \n",
" \n",
" 2 | \n",
" \n",
"
\n",
" \n",
" \n",
" e | \n",
" \n",
" 5 | \n",
" \n",
" 1 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" f | \n",
" \n",
" 6 | \n",
" \n",
" 0 | \n",
" \n",
" 0 | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
"\n",
"
"
],
"text/plain": [
"#\n",
" a b c\n",
" a 1 1 1\n",
" b 2 5 6\n",
" c 3 2 7\n",
" d 4 5 2\n",
" e 5 1 6\n",
" f 6 0 0"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = Daru::DataFrame.new(\n",
" {\n",
" a: [1, 2, 3, 4, 5, 6],\n",
" b: [1, 5, 2, 5, 1, 0],\n",
" c: [1, 6, 7, 2, 6, 0]\n",
" }, index: 'a'..'f'\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"#\n",
" a b c\n",
" a 1 1 1\n",
" b 2 5 6\n",
" c 3 2 7\n",
" d 4 5 2\n",
" e 5 1 6\n",
" f 6 0 0, @options={:type=>:line, :x=>:a, :y=>:c}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#[#:line, :options=>{:x=>:a, :y=>:c}, :data=>\"dd735a9c-1a93-440f-ab9f-db39f5e11f96\"}, @xrange=[1, 6], @yrange=[0, 7]>], :options=>{}}>>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plt = Daru::View::Plot.new(df, type: :line, x: :a, y: :c) "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
],
"text/plain": [
"#[#[#:line, :options=>{:x=>:a, :y=>:c}, :data=>\"dd735a9c-1a93-440f-ab9f-db39f5e11f96\"}, @xrange=[1, 6], @yrange=[0, 7]>], :options=>{:zoom=>true, :width=>700, :xrange=>[1, 6], :yrange=>[0, 7]}}>], :data=>{\"dd735a9c-1a93-440f-ab9f-db39f5e11f96\"=>#1, :b=>1, :c=>1}, {:a=>2, :b=>5, :c=>6}, {:a=>3, :b=>2, :c=>7}, {:a=>4, :b=>5, :c=>2}, {:a=>5, :b=>1, :c=>6}, {:a=>6, :b=>0, :c=>0}]>}, :extension=>[]}>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.show_in_iruby"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/javascript": [
"if(window['d3'] === undefined ||\n",
" window['Nyaplot'] === undefined){\n",
" var path = {\"d3\":\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min\",\"downloadable\":\"http://cdn.rawgit.com/domitry/d3-downloadable/master/d3-downloadable\"};\n",
"\n",
"\n",
"\n",
" var shim = {\"d3\":{\"exports\":\"d3\"},\"downloadable\":{\"exports\":\"downloadable\"}};\n",
"\n",
" require.config({paths: path, shim:shim});\n",
"\n",
"\n",
"require(['d3'], function(d3){window['d3']=d3;console.log('finished loading d3');require(['downloadable'], function(downloadable){window['downloadable']=downloadable;console.log('finished loading downloadable');\n",
"\n",
"\tvar script = d3.select(\"head\")\n",
"\t .append(\"script\")\n",
"\t .attr(\"src\", \"http://cdn.rawgit.com/domitry/Nyaplotjs/master/release/nyaplot.js\")\n",
"\t .attr(\"async\", true);\n",
"\n",
"\tscript[0][0].onload = script[0][0].onreadystatechange = function(){\n",
"\n",
"\n",
"\t var event = document.createEvent(\"HTMLEvents\");\n",
"\t event.initEvent(\"load_nyaplot\",false,false);\n",
"\t window.dispatchEvent(event);\n",
"\t console.log('Finished loading Nyaplotjs');\n",
"\n",
"\t};\n",
"\n",
"\n",
"});});\n",
"}\n"
],
"text/plain": [
"\"if(window['d3'] === undefined ||\\n window['Nyaplot'] === undefined){\\n var path = {\\\"d3\\\":\\\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min\\\",\\\"downloadable\\\":\\\"http://cdn.rawgit.com/domitry/d3-downloadable/master/d3-downloadable\\\"};\\n\\n\\n\\n var shim = {\\\"d3\\\":{\\\"exports\\\":\\\"d3\\\"},\\\"downloadable\\\":{\\\"exports\\\":\\\"downloadable\\\"}};\\n\\n require.config({paths: path, shim:shim});\\n\\n\\nrequire(['d3'], function(d3){window['d3']=d3;console.log('finished loading d3');require(['downloadable'], function(downloadable){window['downloadable']=downloadable;console.log('finished loading downloadable');\\n\\n\\tvar script = d3.select(\\\"head\\\")\\n\\t .append(\\\"script\\\")\\n\\t .attr(\\\"src\\\", \\\"http://cdn.rawgit.com/domitry/Nyaplotjs/master/release/nyaplot.js\\\")\\n\\t .attr(\\\"async\\\", true);\\n\\n\\tscript[0][0].onload = script[0][0].onreadystatechange = function(){\\n\\n\\n\\t var event = document.createEvent(\\\"HTMLEvents\\\");\\n\\t event.initEvent(\\\"load_nyaplot\\\",false,false);\\n\\t window.dispatchEvent(event);\\n\\t console.log('Finished loading Nyaplotjs');\\n\\n\\t};\\n\\n\\n});});\\n}\\n\""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
":nyaplot"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Daru::View.plotting_library = :nyaplot"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"#\n",
" a b c\n",
" a 1 1 1\n",
" b 2 5 6\n",
" c 3 2 7\n",
" d 4 5 2\n",
" e 5 1 6\n",
" f 6 0 0, @options={}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#[], :options=>{}}>>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plt2 = Daru::View::Plot.new(df) "
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
],
"text/plain": [
"#[#[], :options=>{}}>], :data=>{}, :extension=>[]}>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt2.show_in_iruby"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" Daru::Vector(3) \n",
"\n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1 | \n",
"
\n",
" \n",
" \n",
" 1 | \n",
" 2 | \n",
"
\n",
" \n",
" \n",
" 2 | \n",
" 3 | \n",
"
\n",
" \n",
"\n",
" \n",
"\n",
"
"
],
"text/plain": [
"#\n",
" 0 1\n",
" 1 2\n",
" 2 3"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dv = Daru::Vector.new [1, 2, 3] "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"#\n",
" 0 1\n",
" 1 2\n",
" 2 3, @options={}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#[#:scatter, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"56256933-852f-4161-9749-01d058a05cd0\"}, @xrange=[0, 2], @yrange=[1, 3]>], :options=>{}}>>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plt3 = Daru::View::Plot.new(dv)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
],
"text/plain": [
"#[#[#:scatter, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"56256933-852f-4161-9749-01d058a05cd0\"}, @xrange=[0, 2], @yrange=[1, 3]>], :options=>{:zoom=>true, :width=>700, :xrange=>[0, 2], :yrange=>[1, 3]}}>], :data=>{\"56256933-852f-4161-9749-01d058a05cd0\"=>#0, :data1=>1}, {:data0=>1, :data1=>2}, {:data0=>2, :data1=>3}]>}, :extension=>[]}>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt3.show_in_iruby"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"#\n",
" 0 1\n",
" 1 2\n",
" 2 3, @options={:type=>:line}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#[#:line, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"dd9c528c-6fb4-44ef-abc9-0f9cabc53149\"}, @xrange=[0, 2], @yrange=[1, 3]>], :options=>{}}>>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plt3 = Daru::View::Plot.new(dv, type: :line)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
],
"text/plain": [
"#[#[#:line, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"dd9c528c-6fb4-44ef-abc9-0f9cabc53149\"}, @xrange=[0, 2], @yrange=[1, 3]>], :options=>{:zoom=>true, :width=>700, :xrange=>[0, 2], :yrange=>[1, 3]}}>], :data=>{\"dd9c528c-6fb4-44ef-abc9-0f9cabc53149\"=>#0, :data1=>1}, {:data0=>1, :data1=>2}, {:data0=>2, :data1=>3}]>}, :extension=>[]}>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt3.show_in_iruby"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Ruby 2.4.1",
"language": "ruby",
"name": "ruby"
},
"language_info": {
"file_extension": ".rb",
"mimetype": "application/x-ruby",
"name": "ruby",
"version": "2.4.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}