title: Scientific notation in d3.js axis
body: <p>I am trying to plot some extremely small values with d3.js. Is there a direct way to visualise the tick labels in scientific (exponential) notation?</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;style&gt;
  
  &lt;/style&gt;
  &lt;body&gt;
  
  &lt;!-- load the d3.js library --&gt;     
  &lt;script src="//d3js.org/d3.v4.min.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  
  // set the dimensions and margins of the graph
  var margin = {top: 20, right: 20, bottom: 30, left: 50},
      width = 960 - margin.left - margin.right,
      height = 500 - margin.top - margin.bottom;
  
  // parse the date / time
  var data = [[0.3, 5e-300],[0.1, 3e-300],[0.7, 4e-300],[0.2, 7e-300],[0.6, 2.5e-300],[0.9, 4.2e-300]]
  
  // set the ranges
  var x = d3.scaleLinear().range([0, width]).domain([0, d3.max(data, function(d) { return d[0]; })]);
  var y = d3.scaleLinear().range([height, 0]).domain([0, d3.max(data, function(d) { return d[1]; })]);
  
  
  // append the svg obgect to the body of the page
  // appends a 'group' element to 'svg'
  // moves the 'group' element to the top left margin
  var svg = d3.select("body").append("svg")
      .attr("width", width + margin.left + margin.right)
      .attr("height", height + margin.top + margin.bottom)
    .append("g")
      .attr("transform",
            "translate(" + margin.left + "," + margin.top + ")");
  
  svg.selectAll("dot")
      .data(data)
        .enter().append("circle")
        .attr("cx", function (d,i) { return x(d[0]); } )
        .attr("cy", function (d) { return y(d[1]); } )
        .attr("r", 8);
  
  // Add the X Axis
  svg.append("g")
      .attr("transform", "translate(0," + height + ")")
      .call(d3.axisBottom(x));
  
  // Add the Y Axis
  svg.append("g")
      .call(d3.axisLeft(y)
      .tickFormat(d3.formatPrefix(".1s", 1e-300)));;
  
  
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Here's an example created with in matplotlib. I would like to achieve the same thing with regard to y-axis notation</p>
  
  <p><a href="https://i.stack.imgur.com/rpMSU.png" rel="nofollow"><img src="https://i.stack.imgur.com/rpMSU.png" alt="enter image description here"></a></p>