Plotly.js: Automatic (x-)range too narrow

Created on 24 Oct 2016  路  2Comments  路  Source: plotly/plotly.js

Related code pen https://codepen.io/brechmos/pen/JRxVJg.

I have 3 scatter plots of data, each of a single point. Two of them are locked on the far left which is not what I would have expected. I would have expected to see all 3 points on the screen more centered within the plot figure.

I could set the range explicitly in order to get the plot that I was expecting, but it seems like there is a bug in the automatic range code.

bug

Most helpful comment

@brechmos-stsci late reply here, I'm just combing through old bugs.

You've got two points with identical x values and one with a slightly different x. What we try to do in this case is use the full x range (1.9743192951795587 - 1.9743192951795583 = 4e-16) to scale the x axis, then here because there are markers we add 5% to the range on either side so nothing is squished on the edge. But you're really close to the limit of javascript's double precision floating point here, so that we can't actually change the range by 5% - that rounds down to no change at all. This is also why the tick labels fail on that plot.

I suppose we could do something like limit the minimum fractional span of an axis (range[1] - range[0]) / ((range[1] + range[0]) / 2) > 1e-14. That would probably be better than letting things break like this. See also #1320.

All 2 comments

Yeah, that looks like a bug to me too.

Thanks for posting.

@brechmos-stsci late reply here, I'm just combing through old bugs.

You've got two points with identical x values and one with a slightly different x. What we try to do in this case is use the full x range (1.9743192951795587 - 1.9743192951795583 = 4e-16) to scale the x axis, then here because there are markers we add 5% to the range on either side so nothing is squished on the edge. But you're really close to the limit of javascript's double precision floating point here, so that we can't actually change the range by 5% - that rounds down to no change at all. This is also why the tick labels fail on that plot.

I suppose we could do something like limit the minimum fractional span of an axis (range[1] - range[0]) / ((range[1] + range[0]) / 2) > 1e-14. That would probably be better than letting things break like this. See also #1320.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonmmease picture jonmmease  路  3Comments

danielsamuels picture danielsamuels  路  3Comments

tim-sauchuk picture tim-sauchuk  路  3Comments

emanuelsetitinger picture emanuelsetitinger  路  3Comments

nicolaskruchten picture nicolaskruchten  路  3Comments