Skip to content

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

@laura-cbre

Description

@laura-cbre

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}}```


Activity

changed the title [-]Bug: Sometimes boxplots span multiple x axes ticks[/-] [+]Bug: Sometimes boxplots span multiple x axis ticks[/+] on Jan 23, 2020
archmoj

archmoj commented on Jan 23, 2020

@archmoj
Contributor
archmoj

archmoj commented on Jan 23, 2020

@archmoj
Contributor

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

changed the title [-]Bug: Sometimes boxplots span multiple x axis ticks[/-] [+]Bug: Sometimes box and whiskers span multiple x axis ticks[/+] on Jan 23, 2020
etpinard

etpinard commented on Jan 27, 2020

@etpinard
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

alexcjohnson commented on Jan 27, 2020

@alexcjohnson
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

etpinard commented on Jan 27, 2020

@etpinard
Contributor

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

alexcjohnson

alexcjohnson commented on Jan 27, 2020

@alexcjohnson
Collaborator

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

laura-cbre

laura-cbre commented on Jan 28, 2020

@laura-cbre
Author

@etpinard thank you for the workaround, it works nicely

etpinard

etpinard commented on Jan 28, 2020

@etpinard
Contributor

Merging into #1181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @alexcjohnson@etpinard@archmoj@laura-cbre

        Issue actions

          Bug: Sometimes box and whiskers span multiple x axis ticks · Issue #4510 · plotly/plotly.js