日本の各種統計データの可視化 (気候)
1.概要
「Google Chartsを使ってデータの可視化」で各種グラフパターン
を紹介していますが、今回は、その第四弾として、気候データを利用してグラフ化して見ました。
データは総務省統計局が公開している「統計でみる都道府県のすがた 2018」観測年:2016年のオープンデータから
必要部分のみを抜粋して利用しました。e-Statのデータは更新が遅くて少し古いデータしかないのが難点ですね。
2.利用方法 グラフは下記の7種類を作成しました。下記のデモ(DEMO)日本の各種統計データの可視化 (気候)をクリックすると実際のグラフが確認できます。
DEMO 日本の各種統計データの可視化 (気候)
3.ソースコード ソースコードは少し長いので、グラフ本体部分のJavaScriptのみ掲載します。詳細が必要であれば、ブラウザのソースコードの表示などで確認して下さい。
4.ソースコードについて 掲載ソースコードのライセンスは、CC0 (クレジット表示不要、改変可、商用可) とします。自由に利用して頂いてかまいません。 尚、データの取得やプログラム実行において損害等が生じた場合は、筆者は一切の責任も負いません。全て自己責任でお願いします。
■関連記事
・Google Chartsを使ってデータの可視化
・日本の各種統計データの可視化 (人口・国土)
・日本の各種統計データの可視化 (河川・山・湖沼・温泉)
・日本の各種統計データの可視化 (漁業・農業)
2.利用方法 グラフは下記の7種類を作成しました。下記のデモ(DEMO)日本の各種統計データの可視化 (気候)をクリックすると実際のグラフが確認できます。
-
・ 1. 都道府県別の気温
・ 2. 都道府県別の年平均湿度
・ 3. 都道府県別の年間日照時間
・ 4. 都道府県別の年間降水量
・ 5. 都道府県別の年間快晴日数
・ 6. 都道府県別の年間降水日数
・ 7. 都道府県別の年間雪日数
DEMO 日本の各種統計データの可視化 (気候)
3.ソースコード ソースコードは少し長いので、グラフ本体部分のJavaScriptのみ掲載します。詳細が必要であれば、ブラウザのソースコードの表示などで確認して下さい。
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="./css/graphdemo.css">
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart1);
google.charts.setOnLoadCallback(drawChart2);
google.charts.setOnLoadCallback(drawChart3);
google.charts.setOnLoadCallback(drawChart4);
google.charts.setOnLoadCallback(drawChart5);
google.charts.setOnLoadCallback(drawChart6);
google.charts.setOnLoadCallback(drawChart7);
//***** 1折れ線グラフ(都道府県別の気温(2016年)) *****
function drawChart1() {
var data = google.visualization.arrayToDataTable([
["都道府県", "年平均気温","月最高気温","月最低気温" ],
["北海道", 9.3,28.3,-5.9],
["青森県", 11.0,28.7,-3.0],
["岩手県", 11.2,30.5,-3.6],
["宮城県", 13.5,29.9,-0.8],
["秋田県", 12.5,31.4,-1.7],
["山形県", 12.7,31.4,-2.1],
["福島県", 14.2,31.6,-0.6],
["茨城県", 14.8,30.5,-1.0],
["栃木県", 14.8,31.4,-1.6],
["群馬県", 15.6,31.5,-0.2],
["埼玉県", 15.9,32.3,-0.5],
["千葉県", 16.8,31.2,3.0],
["東京都", 16.4,31.6,1.8],
["神奈川県", 16.9,31.3,3.4],
["新潟県", 14.5,31.1,0.7],
["富山県", 15.2,31.3,1.0],
["石川県", 15.7,31.8,1.5],
["福井県", 15.6,32.3,1.0],
["山梨県", 15.7,33.4,-2.3],
["長野県", 13.1,31.9,-3.8],
["岐阜県", 16.9,34.3,1.7],
["静岡県", 17.6,32.3,2.3],
["愛知県", 17.0,33.8,1.9],
["三重県", 16.9,32.2,2.9],
["滋賀県", 15.8,32.9,1.4],
["京都府", 17.1,34.7,2.0],
["大阪府", 17.7,35.0,3.4],
["兵庫県", 17.8,33.7,3.9],
["奈良県", 16.0,34.3,0.5],
["和歌山県", 17.7,33.9,3.6],
["鳥取県", 16.0,33.0,1.3],
["島根県", 15.9,32.2,1.5],
["岡山県", 16.6,34.3,0.8],
["広島県", 17.2,34.3,2.3],
["山口県", 16.5,34.2,0.7],
["徳島県", 17.6,33.9,3.5],
["香川県", 17.5,34.5,2.8],
["愛媛県", 17.6,34.0,3.2],
["高知県", 18.1,33.7,2.7],
["福岡県", 18.1,34.3,4.2],
["佐賀県", 17.9,35.0,2.6],
["長崎県", 18.1,33.7,4.2],
["熊本県", 18.0,35.1,2.2],
["大分県", 17.6,33.9,2.8],
["宮崎県", 18.6,32.7,3.9],
["鹿児島県", 19.6,34.4,5.4],
["沖縄県", 24.1,32.6,14.4]
]);
var view = new google.visualization.DataView(data);
var options = {
'title': "1.都道府県別の気温(2016年) 単位:(℃)",
'width':800,
'height': 400,
'lineWidth': 2, 'pointSize': 6,
'titleTextStyle': { fontSize: 16,color:'#0000dd' },
'bar': { groupWidth: '85%' },
'chartArea':{left:60,top:60,width:'100%',height:'65%'},
'legend': { position: 'top' },
'vAxis': {'textStyle':{fontSize: 11,color:'#000000'}},
'hAxis': {'slantedText':true,'slantedTextAngle':90,'textStyle': {fontSize: 12,color:'#000000'}}
};
var chart= new google.visualization.LineChart(document.getElementById('chart_div1'));
chart.draw(data, options);
}
//***** 2.縦棒グラフ(都道府県別の年平均湿度(2016年)) *****
function drawChart2() {
var data = google.visualization.arrayToDataTable([
["都道府県", "年平均湿度" ],
["北海道", 66],
["青森県", 76],
["岩手県", 74],
["宮城県", 68],
["秋田県", 74],
["山形県", 71],
["福島県", 69],
["茨城県", 74],
["栃木県", 68],
["群馬県", 63],
["埼玉県", 63],
["千葉県", 67],
["東京都", 69],
["神奈川県", 70],
["新潟県", 74],
["富山県", 72],
["石川県", 70],
["福井県", 72],
["山梨県", 63],
["長野県", 73],
["岐阜県", 65],
["静岡県", 69],
["愛知県", 65],
["三重県", 66],
["滋賀県", 73],
["京都府", 66],
["大阪府", 65],
["兵庫県", 65],
["奈良県", 76],
["和歌山県", 68],
["鳥取県", 75],
["島根県", 78],
["岡山県", 72],
["広島県", 65],
["山口県", 78],
["徳島県", 71],
["香川県", 69],
["愛媛県", 70],
["高知県", 71],
["福岡県", 73],
["佐賀県", 73],
["長崎県", 75],
["熊本県", 75],
["大分県", 72],
["宮崎県", 77],
["鹿児島県", 75],
["沖縄県", 74]
]);
var view = new google.visualization.DataView(data);
var options = {
'title': "2.都道府県別の年平均湿度(2016年) 単位:(%)",
'width': 800,
'height': 400,
'titleTextStyle': {fontSize:16,color:'#0000dd'},
'bar': {groupWidth: "75%"},
'legend': {position: "none"},
'chartArea':{left:60,top:60,width:'100%',height:'65%'},
'vAxis': {'textStyle':{fontSize: 11,color:'#000000'}},
'hAxis': {'slantedText':true,'slantedTextAngle':90,'textStyle': {fontSize: 12,color:'#000000'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById("chart_div2"));
chart.draw(view, options);
}
//***** 3.縦棒グラフ(都道府県別の年間日照時間(2016年)) *****
function drawChart3() {
var data = google.visualization.arrayToDataTable([
["都道府県", "年間日照時間", { role: "style" } ],
["北海道", 1819,"color: #ff9900"],
["青森県", 1622,"color: #ff9900"],
["岩手県", 1824,"color: #ff9900"],
["宮城県", 1896,"color: #ff9900"],
["秋田県", 1674,"color: #ff9900"],
["山形県", 1683,"color: #ff9900"],
["福島県", 1818,"color: #ff9900"],
["茨城県", 2062,"color: #ff9900"],
["栃木県", 1936,"color: #ff9900"],
["群馬県", 2129,"color: #ff9900"],
["埼玉県", 2071,"color: #ff9900"],
["千葉県", 1857,"color: #ff9900"],
["東京都", 1842,"color: #ff9900"],
["神奈川県", 1935,"color: #ff9900"],
["新潟県", 1738,"color: #ff9900"],
["富山県", 1680,"color: #ff9900"],
["石川県", 1802,"color: #ff9900"],
["福井県", 1733,"color: #ff9900"],
["山梨県", 2188,"color: #ff9900"],
["長野県", 2022,"color: #ff9900"],
["岐阜県", 2135,"color: #ff9900"],
["静岡県", 2099,"color: #ff9900"],
["愛知県", 2168,"color: #ff9900"],
["三重県", 2144,"color: #ff9900"],
["滋賀県", 2013,"color: #ff9900"],
["京都府", 1847,"color: #ff9900"],
["大阪府", 2127,"color: #ff9900"],
["兵庫県", 2115,"color: #ff9900"],
["奈良県", 1887,"color: #ff9900"],
["和歌山県", 2155,"color: #ff9900"],
["鳥取県", 1713,"color: #ff9900"],
["島根県", 1664,"color: #ff9900"],
["岡山県", 1996,"color: #ff9900"],
["広島県", 1897,"color: #ff9900"],
["山口県", 1781,"color: #ff9900"],
["徳島県", 2099,"color: #ff9900"],
["香川県", 2029,"color: #ff9900"],
["愛媛県", 1925,"color: #ff9900"],
["高知県", 2097,"color: #ff9900"],
["福岡県", 1832,"color: #ff9900"],
["佐賀県", 1863,"color: #ff9900"],
["長崎県", 1782,"color: #ff9900"],
["熊本県", 1932,"color: #ff9900"],
["大分県", 1913,"color: #ff9900"],
["宮崎県", 2051,"color: #ff9900"],
["鹿児島県", 1946,"color: #ff9900"],
["沖縄県", 1757,"color: #ff9900"]
]);
var view = new google.visualization.DataView(data);
var options = {
'title': "3.都道府県別の年間日照時間(2016年) 単位:(hours)",
'width': 800,
'height': 400,
'titleTextStyle': {fontSize:16,color:'#0000dd'},
'bar': {groupWidth: "75%"},
'legend': {position: "none"},
'chartArea':{left:60,top:60,width:'100%',height:'65%'},
'vAxis': {'textStyle':{fontSize: 11,color:'#000000'}},
'hAxis': {'slantedText':true,'slantedTextAngle':90,'textStyle': {fontSize: 12,color:'#000000'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById("chart_div3"));
chart.draw(view, options);
}
//***** 4.縦棒グラフ(都道府県別の年間降水量(2016年)) *****
function drawChart4() {
var data = google.visualization.arrayToDataTable([
["都道府県", "年間降水量", { role: "style" } ],
["北海道", 1360,"color: #0099c6"],
["青森県", 1390,"color: #0099c6"],
["岩手県", 1318,"color: #0099c6"],
["宮城県", 1209,"color: #0099c6"],
["秋田県", 1796,"color: #0099c6"],
["山形県", 1244,"color: #0099c6"],
["福島県", 1172,"color: #0099c6"],
["茨城県", 1426,"color: #0099c6"],
["栃木県", 1592,"color: #0099c6"],
["群馬県", 1249,"color: #0099c6"],
["埼玉県", 1301,"color: #0099c6"],
["千葉県", 1605,"color: #0099c6"],
["東京都", 1779,"color: #0099c6"],
["神奈川県", 1970,"color: #0099c6"],
["新潟県", 1499,"color: #0099c6"],
["富山県", 2336,"color: #0099c6"],
["石川県", 2391,"color: #0099c6"],
["福井県", 2027,"color: #0099c6"],
["山梨県", 1125,"color: #0099c6"],
["長野県", 923,"color: #0099c6"],
["岐阜県", 1988,"color: #0099c6"],
["静岡県", 2442,"color: #0099c6"],
["愛知県", 1686,"color: #0099c6"],
["三重県", 1786,"color: #0099c6"],
["滋賀県", 1629,"color: #0099c6"],
["京都府", 1840,"color: #0099c6"],
["大阪府", 1454,"color: #0099c6"],
["兵庫県", 1347,"color: #0099c6"],
["奈良県", 1494,"color: #0099c6"],
["和歌山県", 1508,"color: #0099c6"],
["鳥取県", 1795,"color: #0099c6"],
["島根県", 1800,"color: #0099c6"],
["岡山県", 1513,"color: #0099c6"],
["広島県", 2124,"color: #0099c6"],
["山口県", 2493,"color: #0099c6"],
["徳島県", 1715,"color: #0099c6"],
["香川県", 1286,"color: #0099c6"],
["愛媛県", 1584,"color: #0099c6"],
["高知県", 2823,"color: #0099c6"],
["福岡県", 2421,"color: #0099c6"],
["佐賀県", 2586,"color: #0099c6"],
["長崎県", 2293,"color: #0099c6"],
["熊本県", 2504,"color: #0099c6"],
["大分県", 2199,"color: #0099c6"],
["宮崎県", 2952,"color: #0099c6"],
["鹿児島県", 3286,"color: #0099c6"],
["沖縄県", 2368,"color: #0099c6"]
]);
var view = new google.visualization.DataView(data);
var options = {
'title': "4.都道府県別の年間降水量(2016年) 単位:(mm)",
'width': 800,
'height': 400,
'titleTextStyle': {fontSize:16,color:'#0000dd'},
'bar': {groupWidth: "75%"},
'legend': {position: "none"},
'chartArea':{left:60,top:60,width:'100%',height:'65%'},
'vAxis': {'textStyle':{fontSize: 11,color:'#000000'}},
'hAxis': {'slantedText':true,'slantedTextAngle':90,'textStyle': {fontSize: 12,color:'#000000'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById("chart_div4"));
chart.draw(view, options);
}
//***** 5.面グラフ(都道府県別の年間快晴日数(2016年)) *****
function drawChart5() {
var data = google.visualization.arrayToDataTable([
["都道府県", "年間快晴日数", { role: "style" } ],
["北海道", 16,"color: #ff9900"],
["青森県", 13,"color: #ff9900"],
["岩手県", 11,"color: #ff9900"],
["宮城県", 12,"color: #ff9900"],
["秋田県", 9,"color: #ff9900"],
["山形県", 11,"color: #ff9900"],
["福島県", 11,"color: #ff9900"],
["茨城県", 31,"color: #ff9900"],
["栃木県", 34,"color: #ff9900"],
["群馬県", 46,"color: #ff9900"],
["埼玉県", 56,"color: #ff9900"],
["千葉県", 19,"color: #ff9900"],
["東京都", 24,"color: #ff9900"],
["神奈川県", 24,"color: #ff9900"],
["新潟県", 10,"color: #ff9900"],
["富山県", 15,"color: #ff9900"],
["石川県", 11,"color: #ff9900"],
["福井県", 12,"color: #ff9900"],
["山梨県", 28,"color: #ff9900"],
["長野県", 16,"color: #ff9900"],
["岐阜県", 36,"color: #ff9900"],
["静岡県", 40,"color: #ff9900"],
["愛知県", 32,"color: #ff9900"],
["三重県", 34,"color: #ff9900"],
["滋賀県", 23,"color: #ff9900"],
["京都府", 12,"color: #ff9900"],
["大阪府", 15,"color: #ff9900"],
["兵庫県", 14,"color: #ff9900"],
["奈良県", 15,"color: #ff9900"],
["和歌山県", 17,"color: #ff9900"],
["鳥取県", 9,"color: #ff9900"],
["島根県", 14,"color: #ff9900"],
["岡山県", 25,"color: #ff9900"],
["広島県", 20,"color: #ff9900"],
["山口県", 23,"color: #ff9900"],
["徳島県", 19,"color: #ff9900"],
["香川県", 18,"color: #ff9900"],
["愛媛県", 17,"color: #ff9900"],
["高知県", 31,"color: #ff9900"],
["福岡県", 15,"color: #ff9900"],
["佐賀県", 24,"color: #ff9900"],
["長崎県", 20,"color: #ff9900"],
["熊本県", 22,"color: #ff9900"],
["大分県", 24,"color: #ff9900"],
["宮崎県", 40,"color: #ff9900"],
["鹿児島県", 24,"color: #ff9900"],
["沖縄県", 4,"color: #ff9900"],
["", 0,"color: #ff9900"],
]);
var view = new google.visualization.DataView(data);
var options = {
'title': "5.都道府県別の年間快晴日数(2016年) 単位:(日)",
'width': 800,
'height': 400,
'titleTextStyle': {fontSize:16,color:'#0000dd'},
'bar': {groupWidth: "75%"},
'legend': {position: "none"},
'chartArea':{left:60,top:60,width:'100%',height:'65%'},
'vAxis': {'textStyle':{fontSize: 11,color:'#000000'}},
'hAxis': {'slantedText':true,'slantedTextAngle':90,'textStyle': {fontSize: 12,color:'#000000'}}
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div5'));
chart.draw(data, options);
}
//***** 6.面グラフ(都道府県別の年間降水日数(2016年)) *****
function drawChart6() {
var data = google.visualization.arrayToDataTable([
["都道府県", "年間快晴日数", { role: "style" } ],
["北海道", 152,"color: #0099c6"],
["青森県", 170,"color: #0099c6"],
["岩手県", 124,"color: #0099c6"],
["宮城県", 90,"color: #0099c6"],
["秋田県", 171,"color: #0099c6"],
["山形県", 129,"color: #0099c6"],
["福島県", 95,"color: #0099c6"],
["茨城県", 98,"color: #0099c6"],
["栃木県", 108,"color: #0099c6"],
["群馬県", 99,"color: #0099c6"],
["埼玉県", 101,"color: #0099c6"],
["千葉県", 107,"color: #0099c6"],
["東京都", 113,"color: #0099c6"],
["神奈川県", 116,"color: #0099c6"],
["新潟県", 164,"color: #0099c6"],
["富山県", 171,"color: #0099c6"],
["石川県", 177,"color: #0099c6"],
["福井県", 165,"color: #0099c6"],
["山梨県", 97,"color: #0099c6"],
["長野県", 93,"color: #0099c6"],
["岐阜県", 113,"color: #0099c6"],
["静岡県", 107,"color: #0099c6"],
["愛知県", 114,"color: #0099c6"],
["三重県", 115,"color: #0099c6"],
["滋賀県", 124,"color: #0099c6"],
["京都府", 112,"color: #0099c6"],
["大阪府", 105,"color: #0099c6"],
["兵庫県", 96,"color: #0099c6"],
["奈良県", 109,"color: #0099c6"],
["和歌山県", 100,"color: #0099c6"],
["鳥取県", 163,"color: #0099c6"],
["島根県", 154,"color: #0099c6"],
["岡山県", 95,"color: #0099c6"],
["広島県", 109,"color: #0099c6"],
["山口県", 132,"color: #0099c6"],
["徳島県", 105,"color: #0099c6"],
["香川県", 92,"color: #0099c6"],
["愛媛県", 111,"color: #0099c6"],
["高知県", 125,"color: #0099c6"],
["福岡県", 134,"color: #0099c6"],
["佐賀県", 121,"color: #0099c6"],
["長崎県", 127,"color: #0099c6"],
["熊本県", 127,"color: #0099c6"],
["大分県", 102,"color: #0099c6"],
["宮崎県", 122,"color: #0099c6"],
["鹿児島県", 132,"color: #0099c6"],
["沖縄県", 145,"color: #0099c6"],
["", 0,"color: #0099c6"],
]);
var view = new google.visualization.DataView(data);
var options = {
'title': "6.都道府県別の年間降水日数(2016年) 単位:(日)",
'width': 800,
'height': 400,
'titleTextStyle': {fontSize:16,color:'#0000dd'},
'bar': {groupWidth: "75%"},
'legend': {position: "none"},
'chartArea':{left:60,top:60,width:'100%',height:'65%'},
'vAxis': {'textStyle':{fontSize: 11,color:'#000000'}},
'hAxis': {'slantedText':true,'slantedTextAngle':90,'textStyle': {fontSize: 12,color:'#000000'}}
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div6'));
chart.draw(data, options);
}
//***** 6.面グラフ(都道府県別の年間雪日数(2016年)) *****
function drawChart7() {
var data = google.visualization.arrayToDataTable([
["都道府県", "年間雪日数", { role: "style" } ],
["北海道", 114,"color: #cccccc"],
["青森県", 95,"color: #cccccc"],
["岩手県", 77,"color: #cccccc"],
["宮城県", 47,"color: #cccccc"],
["秋田県", 90,"color: #cccccc"],
["山形県", 72,"color: #cccccc"],
["福島県", 57,"color: #cccccc"],
["茨城県", 15,"color: #cccccc"],
["栃木県", 19,"color: #cccccc"],
["群馬県", 8,"color: #cccccc"],
["埼玉県", 9,"color: #cccccc"],
["千葉県", 19,"color: #cccccc"],
["東京都", 6,"color: #cccccc"],
["神奈川県", 7,"color: #cccccc"],
["新潟県", 60,"color: #cccccc"],
["富山県", 45,"color: #cccccc"],
["石川県", 44,"color: #cccccc"],
["福井県", 40,"color: #cccccc"],
["山梨県", 12,"color: #cccccc"],
["長野県", 60,"color: #cccccc"],
["岐阜県", 14,"color: #cccccc"],
["静岡県", 1,"color: #cccccc"],
["愛知県", 12,"color: #cccccc"],
["三重県", 7,"color: #cccccc"],
["滋賀県", 21,"color: #cccccc"],
["京都府", 9,"color: #cccccc"],
["大阪府", 9,"color: #cccccc"],
["兵庫県", 7,"color: #cccccc"],
["奈良県", 8,"color: #cccccc"],
["和歌山県", 7,"color: #cccccc"],
["鳥取県", 34,"color: #cccccc"],
["島根県", 34,"color: #cccccc"],
["岡山県", 9,"color: #cccccc"],
["広島県", 15,"color: #cccccc"],
["山口県", 46,"color: #cccccc"],
["徳島県", 8,"color: #cccccc"],
["香川県", 9,"color: #cccccc"],
["愛媛県", 11,"color: #cccccc"],
["高知県", 6,"color: #cccccc"],
["福岡県", 17,"color: #cccccc"],
["佐賀県", 11,"color: #cccccc"],
["長崎県", 11,"color: #cccccc"],
["熊本県", 12,"color: #cccccc"],
["大分県", 8,"color: #cccccc"],
["宮崎県", 3,"color: #cccccc"],
["鹿児島県", 5,"color: #cccccc"],
["沖縄県", 0,"color: #cccccc"],
["", 0,"color: #cccccc"],
]);
var view = new google.visualization.DataView(data);
var options = {
'title': "7.都道府県別の年間雪日数(2016年) 単位:(日)",
'width': 800,
'height': 400,
'titleTextStyle': {fontSize:16,color:'#0000dd'},
'bar': {groupWidth: "75%"},
'legend': {position: "none"},
'chartArea':{left:60,top:60,width:'100%',height:'65%'},
'vAxis': {'textStyle':{fontSize: 11,color:'#000000'}},
'hAxis': {'slantedText':true,'slantedTextAngle':90,'textStyle': {fontSize: 12,color:'#000000'}}
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div7'));
chart.draw(data, options);
}
</script>
</head>
4.ソースコードについて 掲載ソースコードのライセンスは、CC0 (クレジット表示不要、改変可、商用可) とします。自由に利用して頂いてかまいません。 尚、データの取得やプログラム実行において損害等が生じた場合は、筆者は一切の責任も負いません。全て自己責任でお願いします。
■関連記事
・Google Chartsを使ってデータの可視化
・日本の各種統計データの可視化 (人口・国土)
・日本の各種統計データの可視化 (河川・山・湖沼・温泉)
・日本の各種統計データの可視化 (漁業・農業)


コメント
コメントを投稿