{
"metadata": {
"language": "ruby",
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"require 'nyaplot'\n",
"require 'mapnya'"
],
"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\\\", \\\"https://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\""
]
},
{
"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\\\",\\\"Mapnya\\\":\\\"https://rawgit.com/domitry/nyaplot/master/lib/mapnya/js/release/mapnya\\\"};\\n\\n\\n\\n var shim = {\\\"d3\\\":{\\\"exports\\\":\\\"d3\\\"},\\\"Mapnya\\\":{\\\"exports\\\":\\\"Mapnya\\\"}};\\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\\\", \\\"https://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\\nrequire(['Mapnya'], function(Mapnya){window['Mapnya']=Mapnya;console.log('finished loading Mapnya');\\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": 1,
"metadata": {},
"source": [
"Case 1: The bubble chart"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Mapnya bundles [countries](https://github.com/mledoze/countries) as its default map and dataset.It prepares Nyaplot::Countries as the usefult wraper for countries. Nyaplot::Countries.df shows its default dataframe. The dataframe countains information of each country, like name, cca3, location(lat and lng), region, and area."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"raw_df = Nyaplot::Countries.df"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"
name | nativeName | tld | cca2 | ccn3 | cca3 | currency | callingCode | capital | altSpellings | relevance | region | subregion | language | languageCodes | translations | demonym | borders | area | lat | lng |
---|
Afghanistan | \u0627\u0641\u063a\u0627\u0646\u0633\u062a\u0627\u0646 | [\".af\"] | AF | 004 | AFG | [\"AFN\"] | [\"93\"] | Kabul | [\"AF\", \"Af\u0121\u0101nist\u0101n\"] | 0 | Asia | Southern Asia | [\"Pashto\", \"Dari\"] | [\"ps\", \"uz\", \"tk\"] | {\"cy\"=>\"Affganistan\", \"de\"=>\"Afghanistan\", \"es\"=>\"Afganist\u00e1n\", \"fr\"=>\"Afghanistan\", \"it\"=>\"Afghanistan\", \"ja\"=>\"\u30a2\u30d5\u30ac\u30cb\u30b9\u30bf\u30f3\", \"nl\"=>\"Afghanistan\", \"hr\"=>\"Afganistan\", \"ru\"=>\"\u0410\u0444\u0433\u0430\u043d\u0438\u0441\u0442\u0430\u043d\"} | Afghan | [\"IRN\", \"PAK\", \"TKM\", \"UZB\", \"TJK\", \"CHN\"] | 652230 | 33 | 65 |
\u00c5land Islands | \u00c5land | [\".ax\"] | AX | 248 | ALA | [\"EUR\"] | [\"358\"] | Mariehamn | [\"AX\", \"Aaland\", \"Aland\", \"Ahvenanmaa\"] | 0 | Europe | Northern Europe | [\"Swedish\"] | [\"sv\"] | {\"de\"=>\"\u00c5land\", \"es\"=>\"Alandia\", \"fr\"=>\"\u00c5land\", \"it\"=>\"Isole Aland\", \"ja\"=>\"\u30aa\u30fc\u30e9\u30f3\u30c9\u8af8\u5cf6\", \"nl\"=>\"\u00c5landeilanden\", \"hr\"=>\"\u00c5landski otoci\", \"ru\"=>\"\u0410\u043b\u0430\u043d\u0434\u0441\u043a\u0438\u0435 \u043e\u0441\u0442\u0440\u043e\u0432\u0430\"} | \u00c5landish | [] | 0 | 60.116667 | 19.9 |
Albania | Shqip\u00ebria | [\".al\"] | AL | 008 | ALB | [\"ALL\"] | [\"355\"] | Tirana | [\"AL\", \"Shqip\u00ebri\", \"Shqip\u00ebria\", \"Shqipnia\"] | 0 | Europe | Southern Europe | [\"Albanian\"] | [\"sq\"] | {\"cy\"=>\"Albania\", \"de\"=>\"Albanien\", \"es\"=>\"Albania\", \"fr\"=>\"Albanie\", \"it\"=>\"Albania\", \"ja\"=>\"\u30a2\u30eb\u30d0\u30cb\u30a2\", \"nl\"=>\"Albani\u00eb\", \"hr\"=>\"Albanija\", \"ru\"=>\"\u0410\u043b\u0431\u0430\u043d\u0438\u044f\"} | Albanian | [\"MNE\", \"GRC\", \"MKD\", \"KOS\"] | 28748 | 41 | 20 |
Algeria | \u0627\u0644\u062c\u0632\u0627\u0626\u0631 | [\".dz\", \"\u0627\u0644\u062c\u0632\u0627\u0626\u0631.\"] | DZ | 012 | DZA | [\"DZD\"] | [\"213\"] | Algiers | [\"DZ\", \"Dzayer\", \"Alg\u00e9rie\"] | 0 | Africa | Northern Africa | [\"Arabic\"] | [\"ar\"] | {\"cy\"=>\"Algeria\", \"de\"=>\"Algerien\", \"es\"=>\"Argelia\", \"fr\"=>\"Alg\u00e9rie\", \"it\"=>\"Algeria\", \"ja\"=>\"\u30a2\u30eb\u30b8\u30a7\u30ea\u30a2\", \"nl\"=>\"Algerije\", \"hr\"=>\"Al\u017eir\", \"ru\"=>\"\u0410\u043b\u0436\u0438\u0440\"} | Algerian | [\"TUN\", \"LBY\", \"NER\", \"ESH\", \"MRT\", \"MLI\", \"MAR\"] | 2381741 | 28 | 3 |
American Samoa | American Samoa | [\".as\"] | AS | 016 | ASM | [\"USD\"] | [\"1684\"] | Pago Pago | [\"AS\", \"Amerika S\u0101moa\", \"Amelika S\u0101moa\", \"S\u0101moa Amelika\"] | 0.5 | Oceania | Polynesia | [\"English\", \"Samoan\"] | [\"en\", \"sm\"] | {\"de\"=>\"Amerikanisch-Samoa\", \"es\"=>\"Samoa Americana\", \"fr\"=>\"Samoa am\u00e9ricaines\", \"it\"=>\"Samoa Americane\", \"ja\"=>\"\u30a2\u30e1\u30ea\u30ab\u9818\u30b5\u30e2\u30a2\", \"nl\"=>\"Amerikaans Samoa\", \"hr\"=>\"Ameri\u010dka Samoa\", \"ru\"=>\"\u0410\u043c\u0435\u0440\u0438\u043a\u0430\u043d\u0441\u043a\u043e\u0435 \u0421\u0430\u043c\u043e\u0430\"} | American Samoan | [] | 199 | -14.33333333 | -170 |
Andorra | Andorra | [\".ad\"] | AD | 020 | AND | [\"EUR\"] | [\"376\"] | Andorra la Vella | [\"AD\", \"Principality of Andorra\", \"Principat d'Andorra\"] | 0.5 | Europe | Southern Europe | [\"Catalan\"] | [\"ca\"] | {\"cy\"=>\"Andorra\", \"de\"=>\"Andorra\", \"es\"=>\"Andorra\", \"fr\"=>\"Andorre\", \"it\"=>\"Andorra\", \"ja\"=>\"\u30a2\u30f3\u30c9\u30e9\", \"nl\"=>\"Andorra\", \"hr\"=>\"Andora\", \"ru\"=>\"\u0410\u043d\u0434\u043e\u0440\u0440\u0430\"} | Andorran | [\"FRA\", \"ESP\"] | 468 | 42.5 | 1.5 |
Angola | Angola | [\".ao\"] | AO | 024 | AGO | [\"AOA\"] | [\"244\"] | Luanda | [\"AO\", \"Rep\u00fablica de Angola\", \"\u0281\u025bpublika de an'\u0261\u0254la\"] | 0 | Africa | Middle Africa | [\"Portuguese\"] | [\"pt\"] | {\"cy\"=>\"Angola\", \"de\"=>\"Angola\", \"es\"=>\"Angola\", \"fr\"=>\"Angola\", \"it\"=>\"Angola\", \"ja\"=>\"\u30a2\u30f3\u30b4\u30e9\", \"nl\"=>\"Angola\", \"hr\"=>\"Angola\", \"ru\"=>\"\u0410\u043d\u0433\u043e\u043b\u0430\"} | Angolan | [\"COG\", \"COD\", \"ZMB\", \"NAM\"] | 1246700 | -12.5 | 18.5 |
Anguilla | Anguilla | [\".ai\"] | AI | 660 | AIA | [\"XCD\"] | [\"1264\"] | The Valley | [\"AI\"] | 0.5 | Americas | Caribbean | [\"English\"] | [\"en\"] | {\"de\"=>\"Anguilla\", \"es\"=>\"Anguilla\", \"fr\"=>\"Anguilla\", \"it\"=>\"Anguilla\", \"ja\"=>\"\u30a2\u30f3\u30ae\u30e9\", \"nl\"=>\"Anguilla\", \"hr\"=>\"Angvila\", \"ru\"=>\"\u0410\u043d\u0433\u0438\u043b\u044c\u044f\"} | Anguillian | [] | 91 | 18.25 | -63.16666666 |
Antigua and Barbuda | Antigua and Barbuda | [\".ag\"] | AG | 028 | ATG | [\"XCD\"] | [\"1268\"] | Saint John's | [\"AG\"] | 0.5 | Americas | Caribbean | [\"English\"] | [\"en\"] | {\"cy\"=>\"Antigwa a Barbiwda\", \"de\"=>\"Antigua und Barbuda\", \"es\"=>\"Antigua y Barbuda\", \"fr\"=>\"Antigua-et-Barbuda\", \"it\"=>\"Antigua e Barbuda\", \"ja\"=>\"\u30a2\u30f3\u30c6\u30a3\u30b0\u30a2\u30fb\u30d0\u30fc\u30d6\u30fc\u30c0\", \"nl\"=>\"Antigua en Barbuda\", \"hr\"=>\"Antigva i Barbuda\", \"ru\"=>\"\u0410\u043d\u0442\u0438\u0433\u0443\u0430 \u0438 \u0411\u0430\u0440\u0431\u0443\u0434\u0430\"} | Antiguan, Barbudan | [] | 442 | 17.05 | -61.8 |
Argentina | Argentina | [\".ar\"] | AR | 032 | ARG | [\"ARS\"] | [\"54\"] | Buenos Aires | [\"AR\", \"Argentine Republic\", \"Rep\u00fablica Argentina\"] | 0 | Americas | South America | [\"Spanish\"] | [\"es\", \"gn\"] | {\"cy\"=>\"Ariannin\", \"de\"=>\"Argentinien\", \"es\"=>\"Argentina\", \"fr\"=>\"Argentine\", \"it\"=>\"Argentina\", \"ja\"=>\"\u30a2\u30eb\u30bc\u30f3\u30c1\u30f3\", \"nl\"=>\"Argentini\u00eb\", \"hr\"=>\"Argentina\", \"ru\"=>\"\u0410\u0440\u0433\u0435\u043d\u0442\u0438\u043d\u0430\"} | Argentinean | [\"BOL\", \"BRA\", \"CHL\", \"PRY\", \"URY\"] | 2780400 | -34 | -64 |
Armenia | \u0540\u0561\u0575\u0561\u057d\u057f\u0561\u0576 | [\".am\"] | AM | 051 | ARM | [\"AMD\"] | [\"374\"] | Yerevan | [\"AM\", \"Hayastan\", \"Republic of Armenia\", \"\u0540\u0561\u0575\u0561\u057d\u057f\u0561\u0576\u056b \u0540\u0561\u0576\u0580\u0561\u057a\u0565\u057f\u0578\u0582\u0569\u0575\u0578\u0582\u0576\"] | 0 | Asia | Western Asia | [\"Armenian\"] | [\"hy\", \"ru\"] | {\"cy\"=>\"Armenia\", \"de\"=>\"Armenien\", \"es\"=>\"Armenia\", \"fr\"=>\"Arm\u00e9nie\", \"it\"=>\"Armenia\", \"ja\"=>\"\u30a2\u30eb\u30e1\u30cb\u30a2\", \"nl\"=>\"Armeni\u00eb\", \"hr\"=>\"Armenija\", \"ru\"=>\"\u0410\u0440\u043c\u0435\u043d\u0438\u044f\"} | Armenian | [\"AZE\", \"GEO\", \"IRN\", \"TUR\"] | 29743 | 40 | 45 |
Aruba | Aruba | [\".aw\"] | AW | 533 | ABW | [\"AWG\"] | [\"297\"] | Oranjestad | [\"AW\"] | 0.5 | Americas | Caribbean | [\"Dutch\", \"Papiamento\"] | [\"nl\", \"pa\"] | {\"de\"=>\"Aruba\", \"es\"=>\"Aruba\", \"fr\"=>\"Aruba\", \"it\"=>\"Aruba\", \"ja\"=>\"\u30a2\u30eb\u30d0\", \"nl\"=>\"Aruba\", \"hr\"=>\"Aruba\", \"ru\"=>\"\u0410\u0440\u0443\u0431\u0430\"} | Aruban | [] | 180 | 12.5 | -69.96666666 |
Australia | Australia | [\".au\"] | AU | 036 | AUS | [\"AUD\"] | [\"61\"] | Canberra | [\"AU\"] | 1.5 | Oceania | Australia and New Zealand | [\"English\"] | [\"en\"] | {\"cy\"=>\"Awstralia\", \"de\"=>\"Australien\", \"es\"=>\"Australia\", \"fr\"=>\"Australie\", \"it\"=>\"Australia\", \"ja\"=>\"\u30aa\u30fc\u30b9\u30c8\u30e9\u30ea\u30a2\", \"nl\"=>\"Australi\u00eb\", \"hr\"=>\"Australija\", \"ru\"=>\"\u0410\u0432\u0441\u0442\u0440\u0430\u043b\u0438\u044f\"} | Australian | [] | 7692024 | -27 | 133 |
Austria | \u00d6sterreich | [\".at\"] | AT | 040 | AUT | [\"EUR\"] | [\"43\"] | Vienna | [\"AT\", \"\u00d6sterreich\", \"Osterreich\", \"Oesterreich\"] | 0 | Europe | Western Europe | [\"German\"] | [\"de\"] | {\"cy\"=>\"Awstria\", \"de\"=>\"\u00d6sterreich\", \"es\"=>\"Austria\", \"fr\"=>\"Autriche\", \"it\"=>\"Austria\", \"ja\"=>\"\u30aa\u30fc\u30b9\u30c8\u30ea\u30a2\", \"nl\"=>\"Oostenrijk\", \"hr\"=>\"Austrija\", \"ru\"=>\"\u0410\u0432\u0441\u0442\u0440\u0438\u044f\"} | Austrian | [\"CZE\", \"DEU\", \"HUN\", \"ITA\", \"LIE\", \"SVK\", \"SVN\", \"CHE\"] | 83871 | 47.33333333 | 13.33333333 |
Azerbaijan | Az\u0259rbaycan | [\".az\"] | AZ | 031 | AZE | [\"AZN\"] | [\"994\"] | Baku | [\"AZ\", \"Republic of Azerbaijan\", \"Az\u0259rbaycan Respublikas\u0131\"] | 0 | Asia | Western Asia | [\"Azerbaijani\"] | [\"az\", \"hy\"] | {\"cy\"=>\"Aserbaijan\", \"de\"=>\"Aserbaidschan\", \"es\"=>\"Azerbaiy\u00e1n\", \"fr\"=>\"Azerba\u00efdjan\", \"it\"=>\"Azerbaijan\", \"ja\"=>\"\u30a2\u30bc\u30eb\u30d0\u30a4\u30b8\u30e3\u30f3\", \"nl\"=>\"Azerbeidzjan\", \"hr\"=>\"Azerbajd\u017ean\", \"ru\"=>\"\u0410\u0437\u0435\u0440\u0431\u0430\u0439\u0434\u0436\u0430\u043d\"} | Azerbaijani | [\"ARM\", \"GEO\", \"IRN\", \"RUS\", \"TUR\"] | 86600 | 40.5 | 47.5 |
Bahamas | Bahamas | [\".bs\"] | BS | 044 | BHS | [\"BSD\"] | [\"1242\"] | Nassau | [\"BS\", \"Commonwealth of the Bahamas\"] | 0 | Americas | Caribbean | [\"English\"] | [\"en\"] | {\"cy\"=>\"Bahamas\", \"de\"=>\"Bahamas\", \"es\"=>\"Bahamas\", \"fr\"=>\"Bahamas\", \"it\"=>\"Bahamas\", \"ja\"=>\"\u30d0\u30cf\u30de\", \"nl\"=>\"Bahama\u2019s\", \"hr\"=>\"Bahami\", \"ru\"=>\"\u0411\u0430\u0433\u0430\u043c\u0441\u043a\u0438\u0435 \u041e\u0441\u0442\u0440\u043e\u0432\u0430\"} | Bahamian | [] | 13943 | 24.25 | -76 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Zimbabwe | Zimbabwe | [\".zw\"] | ZW | 716 | ZWE | [\"ZWL\"] | [\"263\"] | Harare | [\"ZW\", \"Republic of Zimbabwe\"] | 0 | Africa | Eastern Africa | [\"Chewa\", \"Chibarwe\", \"English\", \"Kalanga\", \"Koisan\", \"Nambya\", \"Ndau\", \"Ndebele\", \"Shangani\", \"Shona\", \"Zimbabwean sign language\", \"Sotho\", \"Tonga\", \"Tswana\", \"Venda\", \"Xhosa\"] | [\"en\", \"sn\", \"nd\"] | {\"de\"=>\"Simbabwe\", \"es\"=>\"Zimbabue\", \"fr\"=>\"Zimbabwe\", \"it\"=>\"Zimbabwe\", \"ja\"=>\"\u30b8\u30f3\u30d0\u30d6\u30a8\", \"nl\"=>\"Zimbabwe\", \"hr\"=>\"Zimbabve\", \"ru\"=>\"\u0417\u0438\u043c\u0431\u0430\u0431\u0432\u0435\"} | Zimbabwean | [\"BWA\", \"MOZ\", \"ZAF\", \"ZMB\"] | 390757 | -20 | 30 |
"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": [
"#