
民主と自民の支持率は完全に逆転してしまった。いま解散すれば自民の単独過半数は確実だ。振り返ったとき、麻生首相の支持率急落のきっかけが「漢字」だったように、民主党内閣の背骨を折ったのは柳田法相の軽卒発言だったということになるだろう。
手法については「社会科学のベイズ統計 動的線形モデルDLM」と同じ。

Google Fusion Tables is a modern data management and publishing web application that makes it easy to host, manage, collaborate on, visualize, and publish data tables online. | |
| |
| グラフのベースになるクラス。めんどくさいことに、ここに追加される立場のpv.Barとpv.Markから継承している属性が多数ある。実際にはBarを継承したオブジェクト(基本的にsvgのrectangle)のコンテナに過ぎないからだ。Protovisは必ず1つ以上のPanel(root)を要求する。root.render()を最後に呼ばなければならない。 | |
| 属性 | 関数 |
| canvas,children, defaults, overflow, transform pv.BarからfillStyle, height, lineWidth, strokeStyle, width pv.Markからbottom, childIndex, cursor, data, events, index, left, parent, proto, reverse, right, root, scale, title, top, type, visible | add(type),anchor(name) pv.MarkからanchorTarget, def, event, extend, margin, mouse, render |
var obj = new pv.Panel().width(280) .height(200).fillStyle(rgb(0, 0, 255)) .root.render(); | |
| この結果、以下のようなSVGが挿入される。 <svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="200" height="200"><rect width="200" height="200" fill="rgb(0,0,255)"> </rect> </svg> | |
var obj = new pv.Panel() .width(150) .height(150) .add(pv.Bar) .data([1, 1.2, 1.7, 1.5, .7]) .bottom(0) .width(20) .height(function(d) d * 80) .left(function() this.index * 25) .root.render(); | |
| この結果、以下のようなSVGが挿入される。 <svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="150" height="150"><g><rect y="70" width="20" height="80" fill="rgb(31,119,180)"></rect><rect x="25" y="54" width="20" height="96" fill="rgb(31,119,180)"></rect><rect x="50" y="14" width="20" height="136" fill="rgb(31,119,180)"></rect><rect x="75" y="30" width="20" height="120" fill="rgb(31,119,180)"></rect><rect x="100" y="94" width="20" height="56" fill="rgb(31,119,180)"></rect></g></svg> | |
| pv.Markから継承している属性が多数ある。widthなど4つを指定しなければならない。 | |
| 属性 | 関数 |
| defaults, height, width, lineWidth, fillStyle, strokeStyle pv.BarからfillStyle, height, lineWidth, strokeStyle, width pv.Markからbottom, childIndex, cursor, data, events, index, left, parent, proto, reverse, right, root, scale, title, top, type, visible | add(type),anchor(name) pv.Markからadd, anchor, anchorTarget, def, event, extend, margin, mouse, render |
var obj = new pv.Panel() .width(150) .height(150) .add(pv.Bar) .data(["red", "orange", "yellow", "green", "blue", "purple"]) .left(0) .right(0) .height(25) .top(function() this.index * 25) .fillStyle(function(d) d) .root.render(); | |
| この結果、以下のようなSVGが挿入される。 <svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="150" height="150"><g><rect width="150" height="25" fill="rgb(255,0,0)"></rect><rect y="25" width="150" height="25" fill="rgb(255,165,0)"></rect><rect y="50" width="150" height="25" fill="rgb(255,255,0)"></rect><rect y="75" width="150" height="25" fill="rgb(0,128,0)"></rect><rect y="100" width="150" height="25" fill="rgb(0,0,255)"></rect><rect y="125" width="150" height="25" fill="rgb(128,0,128)"></rect></g></svg> | |
var obj = new pv.Panel() .width(150) .height(150) .add(pv.Bar) .data([[0, 1], [.5, 1.2], [.9, 1.7], [.2, 1.5], [.7, 2.2]]) .height(20) .bottom(function() this.index * 25) .width(function(d) (d[1] - d[0]) * 50) .left(function(d) d[0] * 50) .root.render(); | |
| この結果、以下のようなSVGが挿入される。 <svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="150" height="150"><g><rect y="130" width="50" height="20" fill="rgb(31,119,180)"></rect><rect x="25" y="105" width="35" height="20" fill="rgb(31,119,180)"></rect><rect x="45" y="80" width="40" height="20" fill="rgb(31,119,180)"></rect><rect x="10" y="55" width="65" height="20" fill="rgb(31,119,180)"></rect><rect x="35" y="30" width="75.00000000000001" height="20" fill="rgb(31,119,180)"></rect></g></svg> | |
| pv.Mark:抽象クラス。後続するAreaなどの基盤になっているだけで、カスタムマークを作るときしか使わない。 | |
| 属性 | 関数 |
| bottom,left,childIndex,cursor,data,defaults,events, index,parent,proto,reverse,root,scale,title,visible | add(type),anchor(name),anchorTarget(), def(name, v),event(type, handler) extend(proto),margin(n),mouse(),render() |
| pv.Area:上下2本の線で囲まれたAreaChartで使う。bottomとheightを指定してやればいい。 | |
var obj = new pv.Panel() .width(150) .height(150) .add(pv.Area) .data([[0, 1], [.5, 1.2], [.9, 1.7], [.5, 1.5], [.4, .7], [.3, .5], [.1, .2]]) .bottom(function(d) d[0] * 80) .height(function(d) (d[1] - d[0]) * 80) .left(function() this.index * 25) .root.render(); | |
| セグメント化できる。 var obj = new pv.Panel() .width(150) .height(150) .add(pv.Area) .segmented(true) .data([1, 1.2, 1.7, 1.5, .7, .5, .2]) .bottom(0) .height(function(d) d * 70) .left(function() this.index * 20 + 15) .fillStyle(function(d) "hsl(" + (d * 180) + ",50%,50%)") .root.render(); | |
| 内挿もしてくれる。 var obj = new pv.Panel() .width(150) .height(150) .add(pv.Area) .data([1, 1.2, 1.7, 1.5, .7, .5, .2]) .bottom(0) .height(function(d) d * 80) .left(function() this.index * 20 + 15) .interpolate("cardinal") .root.render(); | |
| pv.Bar:省略 | |
| pv.Dot:点というより円 | |
var obj = new pv.Panel() .width(150) .height(150) .add(pv.Dot) .data([[.1, 1, .4], [.5, 1.2, .3], [.9, 1.7, .1], [.4, 1.5, 1], [.3, 1.4, 4], [.7, 2.2, 1]] .sort(function(a, b) b[2] - a[2])) .left(function(d) d[0] * 100) .bottom(function(d) d[1] * 50) .size(function(d) d[2] * 200) .strokeStyle("white") .fillStyle("rgba(30, 120, 180, .4)") .root.render(); | |
var obj = new pv.Panel() .width(150) .height(150) .add(pv.Dot) .data([1, 1.2, 1.7, 1.5, .7, .2]) .bottom(function(d) d * 80) .left(function() this.index * 25 + 10) .add(pv.Rule) .height(function() this.proto.bottom() - 5) .bottom(0) .root.render(); | |
| pv:Line:折れ線 | |
var obj = new pv.Panel() .width(150) .height(150) .add(pv.Line) .data([1, 1.2, 1.7, 1.5, .7, .5, .2]) .bottom(function(d) d * 80) .left(function() this.index * 20 + 15) .add(pv.Dot) .root.render(); | |
| Areaと同様、セグメントと内挿が用意されている。 var obj = new pv.Panel() .width(150) .height(150) .add(pv.Line) .data([1, 1.2, 1.7, 1.5, .7, .5, .2]) .bottom(function(d) d * 80) .left(function() this.index * 20 + 15) .interpolate("step-after") .root.render(); | |
| 起点に戻れば多角形になる。 var obj = new pv.Panel() .width(150) .height(150) .add(pv.Line) .data(pv.range(0, 2 * Math.PI, .01)) .left(function(d) Math.cos(d) * (Math.cos(d * 5) + 5) * 10 + 75) .top(function(d) Math.sin(d) * (Math.cos(d * 5) + 5) * 10 + 75) .fillStyle("orange") .root.render(); | |
| pv.Wedge:扇もしくはドーナツの一部 | |
var data = [1, 1.2, 1.7, 1.5, .7], sum = pv.sum(data); var vis = new pv.Panel() .width(150) .height(150); vis.add(pv.Wedge) .data(data) .left(75) .bottom(75) .innerRadius(50) .outerRadius(70) .angle(function(d) d / sum * 2 * Math.PI); vis.render(); | |
var obj = new pv.Panel() .width(150) .height(150) .add(pv.Wedge) .data(pv.normalize([1, 1.2, 1.7, 1.5, .7])) .left(75) .bottom(75) .innerRadius(51) .outerRadius(70) .angle(function(d) d * 2 * Math.PI) .add(pv.Wedge) .data(pv.normalize([.3, .2, 1, 1.5, .4])) .innerRadius(30) .outerRadius(49) .root.render(); | |
| 開始角や終了角を指定することもできる。 var obj = new pv.Panel() .width(150) .height(150) .add(pv.Wedge) .data([1, 1.2, 1.7, 1.5, .7]) .left(75) .bottom(75) .startAngle(Math.PI) .innerRadius(function() this.index * 10 + 20) .outerRadius(function() this.index * 10 + 30) .angle(function(d) d * 2) .root.render(); | |
| pv.Rule:軸やグリッドに使う線 | |
var vis = new pv.Panel() .width(150) .height(150); vis.add(pv.Bar) .data([1, 1.2, 1.7, 1.5, .7]) .bottom(10) .width(20) .height(function(d) d * 70) .left(function() this.index * 25 + 15); vis.add(pv.Rule) .data(pv.range(0, 2, .5)) .bottom(function(d) d * 70 + 9.5) .strokeStyle(function(d) d ? "white" : "black"); vis.render(); | |
| 目盛りも同様。 var vis = new pv.Panel() .width(150) .height(140) .bottom(10); vis.add(pv.Bar) .data([1, 1.2, 1.7, 1.5, .7]) .bottom(0) .width(20) .height(function(d) d * 70) .left(function() this.index * 25 + 15); vis.add(pv.Rule) .bottom(0.5) .add(pv.Rule) .data(pv.range(.5, 2, .5)) .bottom(function(d) d * 70 + .5) .left(0) .width(5); vis.render(); | |
| pv.Image:外部画像 | |
| pv.Label:文字列 | |
| 目盛りの作り方 var vis = new pv.Panel() .width(150) .height(150); vis.add(pv.Bar) .data([1, 1.2, 1.7, 1.5, .7]) .bottom(10) .width(20) .height(function(d) d * 70) .left(function() this.index * 25 + 24); vis.add(pv.Rule) .data(pv.range(4)) .bottom(function(d) d / 2 * 70 + 10) .left(24) .right(6) .strokeStyle(function(d) (d > 0) ? "white" : "black") .add(pv.Label) .textAlign("right") .textBaseline("middle") .text(function(d) (d / 2).toFixed(1)); vis.render(); | |
| 個別値の表示1 var vis = new pv.Panel() .width(150) .height(150); var bar = vis.add(pv.Bar) .data([1, 1.2, 1.7, 1.5, .7, .2]) .bottom(0) .width(20) .height(function(d) d * 80) .left(function() this.index * 25); bar.add(pv.Label) .top(function() bar.top()) .left(function() bar.left() + bar.width() / 2) .textAlign("center") .textBaseline("top") .textStyle("white"); vis.render(); | |
| 個別値の表示2 var data = [1, 1.2, 1.7, 1.5, .7], sum = pv.sum(data); var vis = new pv.Panel() .width(150) .height(150); var wedge = vis.add(pv.Wedge) .data(data) .left(75) .bottom(75) .outerRadius(70) .angle(function(d) d / sum * 2 * Math.PI); wedge.add(pv.Label) .left(function() 45 * Math.cos(wedge.midAngle()) + 75) .bottom(function() -45 * Math.sin(wedge.midAngle()) + 75) .textAlign("center") .textBaseline("middle"); vis.render(); | |
| anchor:マークの位置を言葉で指定することができる | |
var vis = new pv.Panel() .width(150) .height(150); var area = vis.add(pv.Area) .data([1, 1.2, 1.7, 1.5, .7, .5, .2]) .bottom(10) .height(function(d) d * 60) .left(function() this.index * 20 + 10); area.anchor("top").add(pv.Dot) .fillStyle("green"); area.anchor("bottom").add(pv.Dot) .fillStyle("red"); vis.render(); | |
| 下向きに積み上げることができる。extend関数は継承を参照 var vis = new pv.Panel() .width(150) .height(150); var area = vis.add(pv.Area) .data([1, 1.2, 1.7, 1.5, .7, .5, .2]) .bottom(function(d) d * 10 + 55) .height(function(d) d * 30) .left(function() this.index * 22 + 10) .fillStyle(pv.Colors.category20().by(pv.child)); area.anchor("bottom") .extend(area) .add(pv.Area) .data([.4, .2, .8, 1.2, 1.5, 1.1, .8]); vis.render(); | |
| anchorがあるのはMarkの種類によって異なる。 var vis = new pv.Panel().width(150).height(150); var dot = vis.add(pv.Dot).left(75).top(75).size(1000); dot.anchor("top").add(pv.Label).text("top"); dot.anchor("left").add(pv.Label).text("left"); dot.anchor("right").add(pv.Label).text("right"); dot.anchor("bottom").add(pv.Label).text("bottom"); dot.anchor("center").add(pv.Label).text("center"); vis.render(); | |
| Scale:数値変換関数。pv.Scale.linear, pv.Scale.root, pv.Scale.logは連続変換。pv.Scale.ordinalは離散値に変換する | |
var data = pv.range(100).map(Math.random), w = 250, h = 250, x = pv.Scale.linear(0, 100).range(0, w), y = pv.Scale.linear(0, 1).range(0, h), c = pv.Scale.linear(data).range("#1f77b4", "#ff7f0e"); var vis = new pv.Panel() .width(w) .height(h) .margin(20) .strokeStyle("#ccc"); vis.add(pv.Rule) .data(x.ticks()) .strokeStyle("#eee") .left(x) .anchor("bottom").add(pv.Label) .text(x.tickFormat); vis.add(pv.Rule) .data(y.ticks()) .strokeStyle("#eee") .bottom(y) .anchor("right").add(pv.Label) .text(y.tickFormat); vis.add(pv.Dot) .data(data) .left(function() x(this.index)) .bottom(y) .strokeStyle(c) .fillStyle(function(d) c(d).alpha(.2)); vis.render(); | |
var data = [1, 1.2, 1.7, 1.5, .7]; var vis = new pv.Panel() .width(150) .height(150); vis.add(pv.Wedge) .data(data) .left(75) .bottom(75) .innerRadius(50) .outerRadius(70) .angle(pv.Scale.linear(0, pv.sum(data)).range(0, 2 * Math.PI)); vis.render(); | |
| 対数軸の作り方 var data = pv.range(100).map(Math.random), w = 250, h = 250, x = pv.Scale.linear(0, 100).range(0, w), y = pv.Scale.log(0.01, 1).range(0, h), c = pv.Scale.log(data).range("#1f77b4", "#ff7f0e"); var vis = new pv.Panel() .width(w) .height(h) .margin(20) .strokeStyle("#ccc"); vis.add(pv.Rule) .data(x.ticks()) .strokeStyle("#eee") .left(x) .anchor("bottom").add(pv.Label) .text(x.tickFormat); vis.add(pv.Rule) .data(y.ticks()) .strokeStyle("#eee") .bottom(y) .anchor("right").add(pv.Label) .text(y.tickFormat); vis.add(pv.Dot) .data(data) .left(function() x(this.index)) .bottom(y) .strokeStyle(c) .fillStyle(function(d) c(d).alpha(.2)); vis.render(); | |
| 棒グラフの等幅配置する var categories = "ABCDEFGHIJK".split(""), data = categories.map(function(c) [c, Math.random()]), w = 160, h = 360, x = pv.Scale.ordinal(categories).splitBanded(0, w, 4/5), y = pv.Scale.linear(0, 1).range(0, h), c = pv.Colors.category19(categories); var vis = new pv.Panel() .width(w) .height(h) .margin(20) .strokeStyle("#ccc"); vis.add(pv.Bar) .data(data) .left(function(d) x(d[0])) .width(x.range().band) .bottom(0) .height(function(d) y(d[1])) .fillStyle(function(d) c(d[0])) .anchor("bottom").add(pv.Label) .textBaseline("top") .text(function(d) d[0]); vis.add(pv.Rule) .data(y.ticks()) .strokeStyle("rgba(255, 255, 255, .5)") .bottom(y) .anchor("right").add(pv.Label) .text(y.tickFormat); vis.render(); | |

![[HUFF-jump]](http://si.wsj.net/public/resources/images/MK-BJ713A_HUFFj_NS_20110207180003.jpg)
