{ "metadata": { "language": "ruby", "name": "", "signature": "sha256:f46333b609499fd4e355d2c0d6e11c8003949fc5205afe2463552acef09d5fe6" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Nyaplot Tutorial 4: Introduction of charts bundled with Nyaplot" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Various types of diagrams are bundled with Nyaplot, but the usage is not so different. This notebook introduce a part of them." ] }, { "cell_type": "code", "collapsed": false, "input": [ "require 'nyaplot'" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "" ], "metadata": {}, "output_type": "pyout", "prompt_number": 1, "text": [ "\"if(window['d3'] === undefined ||\\n window['Nyaplot'] === undefined){\\n var path = {\\\"d3\\\":\\\"http://d3js.org/d3.v3.min\\\"};\\n\\n\\n\\n var shim = {\\\"d3\\\":{\\\"exports\\\":\\\"d3\\\"}};\\n\\n require.config({paths: path, shim:shim});\\n\\n\\nrequire(['d3'], function(d3){window['d3']=d3;console.log('finished loading d3');\\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": "pyout", "prompt_number": 1, "text": [ "true" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Bar chart" ] }, { "cell_type": "code", "collapsed": false, "input": [ "plot = Nyaplot::Plot.new\n", "plot.add(:bar, ['Persian', 'Maine Coon', 'American Shorthair'], [10,20,30])\n", "plot.x_label(\"Species\")\n", "plot.y_label(\"Number\")\n", "plot.show" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "
\n", "\n" ], "metadata": {}, "output_type": "pyout", "prompt_number": 3, "text": [ "#