Skip to content

Bug: Sometimes box and whiskers span multiple x axis ticks #4510

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
laura-cbre opened this issue Jan 23, 2020 · 8 comments
Closed

Bug: Sometimes box and whiskers span multiple x axis ticks #4510

laura-cbre opened this issue Jan 23, 2020 · 8 comments
Labels
bug something broken

Comments

@laura-cbre
Copy link

laura-cbre commented Jan 23, 2020

I think there is a bug, where plotly will make some box and whiskers overlap another x axis tick, for no reason that I can see.

Example of the problem:
image

Removing one box and whisker solves it:
image

Or adding one box and whisker solves it:
image

The three charts only differ by the number of box and whiskers with data, so I think this might be a bug?

The plotly chart objects fyi in order:

[{"boxpoints": false, "line": {"color": "#e53935"}, "marker": {"color": "#e53935", "line": {"color": "#e53935"}}, "name": "Box 1", "type": "box", "y": [21.0555553333, 21.4358461549, 21.4358461549, 22.33430536877936, 22.3997713193, 22.3997713193, 26.9999997778]}, {"boxpoints": false, "line": {"color": "#8e24aa"}, "marker": {"color": "#8e24aa", "line": {"color": "#8e24aa"}}, "name": "Box 2", "type": "box", "y": [null, null, null, null, null, null, null]}, {"boxpoints": false, "line": {"color": "#3949ab"}, "marker": {"color": "#3949ab", "line": {"color": "#3949ab"}}, "name": "Box 3", "type": "box", "y": [null, null, null, null, null, null, null]}, {"boxpoints": false, "line": {"color": "#039be5"}, "marker": {"color": "#039be5", "line": {"color": "#039be5"}}, "name": "Box 4", "type": "box", "y": [21.1666664444, 21.714605311649997, 21.714605311649997, 23.24186989017084, 24.59777385085, 24.59777385085, 27.8888886667]}, {"boxpoints": false, "line": {"color": "#00897b"}, "marker": {"color": "#00897b", "line": {"color": "#00897b"}}, "name": "Box 5", "type": "box", "y": [null, null, null, null, null, null, null]}, {"boxpoints": false, "line": {"color": "#7cb342"}, "marker": {"color": "#7cb342", "line": {"color": "#7cb342"}}, "name": "Box 6", "type": "box", "y": [null, null, null, null, null, null, null]}],
                        {"bargap": 0, "boxgap": 0, "hoverlabel": {"namelength": -1}, "showlegend": false, "title": {"text": "Bad Boxplot"}, "xaxis": {"automargin": true, "range": [-0.5, 5.5], "rangemode": "normal", "zeroline": false}, "yaxis": {"automargin": true, "hoverformat": ",.1f", "rangemode": "normal", "title": {"text": "degC"}, "zeroline": false}}

[{"boxpoints": false, "line": {"color": "#e53935"}, "marker": {"color": "#e53935", "line": {"color": "#e53935"}}, "name": "Box 1", "type": "box", "y": [null, null, null, null, null, null, null]}, {"boxpoints": false, "line": {"color": "#8e24aa"}, "marker": {"color": "#8e24aa", "line": {"color": "#8e24aa"}}, "name": "Box 2", "type": "box", "y": [null, null, null, null, null, null, null]}, {"boxpoints": false, "line": {"color": "#3949ab"}, "marker": {"color": "#3949ab", "line": {"color": "#3949ab"}}, "name": "Box 3", "type": "box", "y": [null, null, null, null, null, null, null]}, {"boxpoints": false, "line": {"color": "#039be5"}, "marker": {"color": "#039be5", "line": {"color": "#039be5"}}, "name": "Box 4", "type": "box", "y": [21.1666664444, 21.714605311649997, 21.714605311649997, 23.24186989017084, 24.59777385085, 24.59777385085, 27.8888886667]}, {"boxpoints": false, "line": {"color": "#00897b"}, "marker": {"color": "#00897b", "line": {"color": "#00897b"}}, "name": "Box 5", "type": "box", "y": [null, null, null, null, null, null, null]}, {"boxpoints": false, "line": {"color": "#7cb342"}, "marker": {"color": "#7cb342", "line": {"color": "#7cb342"}}, "name": "Box 6", "type": "box", "y": [null, null, null, null, null, null, null]}],
                        {"bargap": 0, "boxgap": 0, "hoverlabel": {"namelength": -1}, "showlegend": false, "title": {"text": "Good Boxplot"}, "xaxis": {"automargin": true, "range": [-0.5, 5.5], "rangemode": "normal", "zeroline": false}, "yaxis": {"automargin": true, "hoverformat": ",.1f", "rangemode": "normal", "title": {"text": "degC"}, "zeroline": false}}

[{"boxpoints": false, "line": {"color": "#e53935"}, "marker": {"color": "#e53935", "line": {"color": "#e53935"}}, "name": "Box 1", "type": "box", "y": [21.0555553333, 21.4358461549, 21.4358461549, 22.33430536877936, 22.3997713193, 22.3997713193, 26.9999997778]}, {"boxpoints": false, "line": {"color": "#8e24aa"}, "marker": {"color": "#8e24aa", "line": {"color": "#8e24aa"}}, "name": "Box 2", "type": "box", "y": [null, null, null, null, null, null, null]}, {"boxpoints": false, "line": {"color": "#3949ab"}, "marker": {"color": "#3949ab", "line": {"color": "#3949ab"}}, "name": "Box 3", "type": "box", "y": [21, 21, 21, 22, 22, 22, 26]}, {"boxpoints": false, "line": {"color": "#039be5"}, "marker": {"color": "#039be5", "line": {"color": "#039be5"}}, "name": "Box 4", "type": "box", "y": [21.1666664444, 21.714605311649997, 21.714605311649997, 23.24186989017084, 24.59777385085, 24.59777385085, 27.8888886667]}, {"boxpoints": false, "line": {"color": "#00897b"}, "marker": {"color": "#00897b", "line": {"color": "#00897b"}}, "name": "Box 5", "type": "box", "y": [null, null, null, null, null, null, null]}, {"boxpoints": false, "line": {"color": "#7cb342"}, "marker": {"color": "#7cb342", "line": {"color": "#7cb342"}}, "name": "Box 6", "type": "box", "y": [null, null, null, null, null, null, null]}],
                        {"bargap": 0, "boxgap": 0, "hoverlabel": {"namelength": -1}, "showlegend": false, "title": {"text": "Good Boxplot"}, "xaxis": {"automargin": true, "range": [-0.5, 5.5], "rangemode": "normal", "zeroline": false}, "yaxis": {"automargin": true, "hoverformat": ",.1f", "rangemode": "normal", "title": {"text": "degC"}, "zeroline": false}}```


@laura-cbre laura-cbre changed the title Bug: Sometimes boxplots span multiple x axes ticks Bug: Sometimes boxplots span multiple x axis ticks Jan 23, 2020
@archmoj
Copy link
Contributor

archmoj commented Jan 23, 2020

Demo using codepen

@archmoj archmoj added the bug something broken label Jan 23, 2020
@archmoj
Copy link
Contributor

archmoj commented Jan 23, 2020

This looks like a bug!
And not a regression.
@laura-cbre thanks very much for reporting.

@laura-cbre laura-cbre changed the title Bug: Sometimes boxplots span multiple x axis ticks Bug: Sometimes box and whiskers span multiple x axis ticks Jan 23, 2020
@etpinard
Copy link
Contributor

Here are the relevant lines:

  • we currently skipped over "empty" boxes when computing the positions:

  • we find the minimum difference between distinct categories (of the non-empty boxes) in:

var boxdv = Lib.distinctVals(pointList);
var dPos0 = boxdv.minDiff / 2;

to compute the width of the boxes.


I'm not sure what we can do at the moment to improve the behaviour in this situation w/o breaking other things.


The easiest workaround is to set width: 1 (or some number smaller than 1) in each of your box traces.

@alexcjohnson
Copy link
Collaborator

I believe we already have special logic for this case already for bar traces - specifically, on a category axis to disallow automatic widths greater than 1.

@etpinard
Copy link
Contributor

As far as I understand, this issue is the box-variant of #1181

@alexcjohnson
Copy link
Collaborator

ha ok, I thought we had solved that but I guess it's still open for bars too

@laura-cbre
Copy link
Author

@etpinard thank you for the workaround, it works nicely

@etpinard
Copy link
Contributor

Merging into #1181

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

No branches or pull requests

4 participants