Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* jasondavies-qq: Improvements to qq chart. Add x- and y-scales to Q-Q plot. Add Q-Q plot.
- Loading branch information
Showing
12 changed files
with
652 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#chart { | ||
font: 10px sans-serif; | ||
width: 960px; | ||
height: 310px; | ||
} | ||
|
||
.qq .box, .qq .tick line, .qq .quantile, .qq .diagonal { | ||
stroke: #aaa; | ||
fill: none; | ||
} | ||
|
||
.qq .quantile { | ||
stroke: #000; | ||
} | ||
|
||
.qq g + g .y.tick { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Q-Q Plots</title> | ||
<script type="text/javascript" src="../../d3.js"></script> | ||
<script type="text/javascript" src="../../d3.chart.js"></script> | ||
<link type="text/css" rel="stylesheet" href="../button.css"/> | ||
<link type="text/css" rel="stylesheet" href="qq.css"/> | ||
</head> | ||
<body> | ||
<div id="chart"> | ||
<button class="first last" onclick="transition()"> | ||
Update | ||
</button> | ||
</div> | ||
<script type="text/javascript" src="stats.js"></script> | ||
<script type="text/javascript" src="qq.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
var w = 280, | ||
h = 280, | ||
m = [10, 0, 20, 35], // top right bottom left | ||
n = 10000; // number of samples to generate | ||
|
||
var chart = d3.chart.qq() | ||
.width(w) | ||
.height(h) | ||
.domain([-.1, 1.1]) | ||
.tickFormat(function(d) { return ~~(d * 100); }); | ||
|
||
var vis = d3.select("#chart") | ||
.append("svg:svg") | ||
.append("svg:g") | ||
.attr("transform", "translate(" + m[3] + "," + m[0] + ")"); | ||
|
||
d3.json("turkers.json", function(turkers) { | ||
var tm = mean(turkers), | ||
td = deviation(turkers), | ||
dd = [ | ||
[0.10306430789206111, 0.0036139086950272735, 0.30498647327844536], | ||
[0.5924252668569606, 0.0462763685758622, 0.4340870312025223], | ||
[0.9847627827855167, 2.352350767874714e-4, 0.2609264955190324] | ||
]; | ||
|
||
var g = vis.selectAll("g") | ||
.data([{ | ||
x: d3.range(n).map(Math.random), | ||
y: turkers, | ||
label: "Uniform Distribution" | ||
}, { | ||
x: d3.range(n).map(normal1(tm, td)), | ||
y: turkers, | ||
label: "Gaussian (Normal) Distribution" | ||
}, { | ||
x: d3.range(n).map(normal3(dd)), | ||
y: turkers, | ||
label: "Mixture of 3 Gaussians" | ||
}]) | ||
.enter().append("svg:g") | ||
.attr("class", "qq") | ||
.attr("transform", function(d, i) { return "translate(" + (w + m[1] + m[3]) * i + ")"; }); | ||
|
||
g.append("svg:rect") | ||
.attr("class", "box") | ||
.attr("width", w) | ||
.attr("height", h); | ||
|
||
g.call(chart); | ||
|
||
g.append("svg:text") | ||
.attr("dy", "1.3em") | ||
.attr("dx", ".6em") | ||
.text(function(d) { return d.label; }); | ||
|
||
chart.duration(1000); | ||
|
||
window.transition = function() { | ||
g.map(randomize).call(chart); | ||
}; | ||
}); | ||
|
||
function randomize(d) { | ||
d.y = d3.range(n).map(Math.random); | ||
return d; | ||
} |
Oops, something went wrong.