This choropleth encodes unemployment rates from 2008 with a quantize scale ranging from 0 to 15%. A threshold scale is a useful alternative for coloring arbitrary ranges.
You need to get to the bit representation of the float, and then:
inline unsigned int float2fint(unsigned int f) {
return f ^ ((-(f >> 31)) | 0x80000000);
}
Callahan et al. used this trick in this paper.
Caveats:
# You should totally ignore this because it's the first piece of Julia I've ever written. | |
# 2-clause BSD, blah. | |
function make_cycle(n) | |
result = Dict{Int32, Array{Int32}}() | |
for i = 1:n | |
ii = i - 1 | |
push!(result, i, [1 + ((i+n-2) % n), 1 + i % n]) | |
end | |
result |
A demo of TopoJSON on a U.S. counties shapefile from the census bureau using d3.geo.albersUsa. The same TopoJSON file can also be used to show counties.
The scatterplot matrix visualizations pairwise correlations for multi-dimensional data; each cell in the matrix is a scatterplot. This example uses Anderson's data of iris flowers on the Gaspé Peninsula. Scatterplot matrix design invented by J. A. Hartigan; see also R and GGobi. Data on Iris flowers collected by Edgar Anderson and published by Ronald Fisher.
See also this version with brushing.
import math | |
from pylab import * | |
def fact(x): | |
return math.gamma(x+1) | |
def choose(n,k): | |
return fact(n) / (fact(k) * fact(n-k)) | |
def hypergeom_mass_at_k(N, K, n, k): |
<html> | |
<head> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.5.0"></script> | |
</head> | |
<body><div id="test"></div> | |
<script> | |
var names = ["v1", | |
"v2", | |
"v3", | |
"v4", |
This example demonstrates how to create a gradient that follows a stroke. This technique is sometimes used to indicate directionality along a curved edge, such as with hierarchical edge bundling.
To start, take any SVG path element and uniformly sample points along the path using getPointAtLength. (This method can also be used for path tweening.) Then, for each segment between adjacent points, compute the miter joint via line-line intersection. Lastly fill each segment by interpolating the start and end colors, here green to red, using the normalized length t along the path. Although each segment is a constant color, there are many segments to give the appearance of a continuous gradient.
This example uses a thin stroke in addition to filling the segments. This avoids antialiasing artifacts due to most
template <typename T> | |
void fun(T* obj) {} | |
template <typename T, void Fun(T*) = fun<T> > | |
struct S { | |
S(int m_sexp) {}; | |
}; | |
template <typename T> | |
S<T> ptr(int s) { return S<T>(s); } |