Skip to content

Scatter Plots over Contour add unwanted padding #937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
daixtrose opened this issue Sep 14, 2016 · 2 comments
Closed

Scatter Plots over Contour add unwanted padding #937

daixtrose opened this issue Sep 14, 2016 · 2 comments

Comments

@daixtrose
Copy link

See https://codepen.io/daixtrose-1471261562/pen/dpGBQO

I draw a countour and 2 scatter lines in the same plot. Without the scatter lines the countour plot fully fills the 1000px times 1000px area as expected after setting

var layout = {
    autosize: false,
    autoexpand: true,
    width: 1000,
    height: 1000,
    margin: {
      l: 0,
      r: 0,
      b: 0,
      t: 0,
      pad: 0
    }, /* ... */

image

Now when I add 2 scatter lines it looks like place above the plot is reserved for the legend even if showlegend: false is set for both of them:

image

@daixtrose
Copy link
Author

Full source:

var data = [{
  x: [0, 1000,   2000,   3000,   4000,   5000,   6000,   6500],
  y: [0, 5,  10, 15, 20, 25, 30],
  z: [
    [ 0.00, 0.00,   0.00,   0.00,   0.00,   0.00,   0.00,   0.00     ],
[ 0.00, 0.00,   0.00,   0.00,   0.00,   0.00,   0.00,   0.00        ],
[ 0.00, 0.00,   0.00,   0.00,   0.00,   0.00,   0.00,   0.00        ],
[ 12.67,    12.67,  12.67,  24.74,  22.31,  10.77,  10.77,  10.77   ],
[ 20.23,    20.23,  20.23,  39.23,  34.31,  34.31,  34.31,  34.31   ],
[ 26.99,    26.99,  26.99,  52.22,  45.18,  45.18,  45.18,  45.18   ],
[ 30.00,    30.00,  30.00,  58.00,  50.00,  50.00,  50.00,  50.00   ]
  ],
  zmin: 0,
  zmax: 1,
  xmin: 0,
  type: 'contour',
  hoverinfo: "none",
  autocontour: false,
  contours: {
    start: 0,
    end: 60,
    size: 3,
    showlines: false
  },
  showscale: false,
  showlegend: false,
  zauto: false,
  colorscale: [
    [0, 'rgb(255, 255, 255)'],
    [1, 'rgb(8, 78, 170)']
  ]
}, {
  x: [ 0, 800, 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500 ],
  y: [ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 ],
  type: 'scatter',
  marker: {
    size: 1
  },
  line: {
    color: 'transparent'
  },
  showlegend: false
}, 
            {
  x: [ 0, 800, 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500 ],
  y: [ 0, 17, 19, 23, 25, 26, 27, 28, 30, 30, 29, 27, 25, 22, 21, 17 ],
  type: 'scatter', 
  fill: 'tonexty',
  marker: {
    size: 1
  }, 
  fillcolor: 'white',
  line: {
    color: '#da1f3d'
  },
  showlegend: false
}];

var layout = {
    autosize: false,
    autoexpand: true,
    width: 1000,
    height: 1000,
    margin: {
      l: 0,
      r: 0,
      b: 0,
      t: 0,
      pad: 0
    },
    xaxis: {
    autorange: true,
    showgrid: false,
    zeroline: false,
    showline: false,
    autotick: true,
    ticks: '1',
    showticklabels: false
  },
  yaxis: {
    autorange: true,
    showgrid: false,
    zeroline: false,
    showline: false,
    autotick: true,
    ticks: '',
    showticklabels: false
  }
}

Plotly.newPlot('myDiv', data, layout);

@etpinard
Copy link
Contributor

That's the desired behaviour under xaxis.autorange / yaxis.autorange true - where the scatter traces present expand the axis with a little more padding than the contour trace by design.

We might want to look at #928 for more info.

In the meantime, setting xaxis.range and yaxis.range to fix values should give you the desired results: https://codepen.io/etpinard/pen/ozxjBg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants