title: D3 difference between ordinal and linear scales
body: <pre><code>var xScale = d3.scale.ordinal().domain([0, d3.max(data)]).rangeRoundBands([0, w], .1);
  var yScale = d3.scale.linear().domain([0, data.length]).range([h, 0]);
  </code></pre>
  
  <p>I'm confused about when to use <strong>ordinal</strong> or <strong>linear</strong> scale in D3.</p>
  
  <p>Below is what I've discovered from the API doc, still bit lost... if anyone can help, it would be much appreciated.</p>
  
  <h1>ordinal(x)</h1>
  
  <p>Given a value x in the input domain, returns the corresponding value in the output range.</p>
  
  <p>If the range was specified explicitly (as by range, but not rangeBands, rangeRoundBands or rangePoints), and the given value x is not in the scale’s domain, then x is implicitly added to the domain; subsequent invocations of the scale given the same value x will return the same value y from the range.</p>
  
  <h1>d3.scale.linear()</h1>
  
  <p>Constructs a new linear scale with the default domain [0,1] and the default range [0,1]. Thus, the default linear scale is equivalent to the identity function for numbers; for example linear(0.5) returns 0.5.</p>