Plotly Contour Bugs

by brian428

HTML

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<!-- Plots go in blank <div> elements. 
    You can size them in the plot layout,
    or give the div a size as shown here.
-->
<div style="width:calc(100%); height: calc(100%); padding: 10px; position: absolute;">
<div id="plotly-div" style="width:100%; height: 90%;"></div>
</div>

JavaScript

// Set to true to see issue with log axis.
var useLogYAxis = true;

var randInRange = function( min, max ) {
  return Math.floor( Math.random() * ( max - min + 1 ) + min );
}

var npoints = 5000;

var buildData = function () {
  var xVals = [];
  var lastX = 200;
  for (var i = 0, l = npoints; i < l; i++) {
    lastX += randInRange( -5, 10 ) + randInRange( -5, 10 );
    xVals.push( lastX );
  };
  
  lastX = 12000;
  for (var i = 0, l = npoints; i < l; i++) {
    lastX += randInRange( -5, 10 );
    xVals.push( lastX );
  };
  
  var yVals = [];
  var lastY = 1000;
  for (var i = 0, l = npoints; i < l; i++) {
    lastY += randInRange( -50, 100 ) + randInRange( -50, 100 )
    yVals.push( lastY );
  };
  
  var lastY = 22000;
  for (var i = 0, l = npoints; i < l; i++) {
    lastY += randInRange( -50, 100 ) + randInRange( -50, 100 )
    yVals.push( lastY );
  };
   
  return {x:xVals, y:yVals};
};

var xyData = buildData();

console.log( xyData );

var trace2 = {
  x: xyData.x, 
  y: xyData.y, 
  name: 'density',
  ncontours: 20,
  colorscale: 'Hot',
  reversescale: true,
  showscale: false,
  type: 'histogram2dcontour'
};
var trace3 = {
  x: xyData.x, 
  name: 'x density',
  marker: {color: 'rgb(102,0,0)'},
  yaxis: 'y2',
  type: 'histogram'
};
var trace4 = {
  y: xyData.y, 
  name: 'y density',
  marker: {color: 'rgb(102,0,0)'},
  xaxis: 'x2',
  type: 'histogram'
};
var data = [trace2, trace3, trace4];
var layout = {
  autosize: 'initial', 
  bargap: 0, 
  //height: null, 
  //width: null, 
  hovermode: "closest", 
  //margin: { t: 40, b: 80, r: 20, l: 80 },
  paper_bgcolor: "white",
  plot_bgcolor: "white",
  showlegend: false, 
  title: "Contour Overflow Bugs", 
  xaxis: {
    autorange: true, 
    domain: [0, 0.85], 
    //range: [-1.75341094962, 2.63743133809], 
    showgrid: false, 
    title: "X Axis", 
    type: "linear", 
    zeroline: false,
    fixedrange: true,
    rangeslider: { borderwidth: 1, thickness: 0.05 }
  }, 
  xaxis2: {
    autorange: true, 
 ...