Skip to content
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

Bug: zorder not working on overlaying subplots #7004

Closed
Farkites opened this issue May 24, 2024 · 1 comment
Closed

Bug: zorder not working on overlaying subplots #7004

Farkites opened this issue May 24, 2024 · 1 comment
Assignees
Labels
bug something broken

Comments

@Farkites
Copy link
Contributor

Description:

On cartesian SVG plots the zorder is not followed by overlaying subplots. Only the traces within the same subplot are ordered by zorder. Since overlaying axes create additional subplots (i.e xy, xy2) the traces in the main subplot are always below the overlaying subplot.

Reproduce this bug:

plotly.js version 2.29.1

Code

var data = [
      {
        "line": {
          "width": 5
        },
        "mode": "lines",
        "name": "x1y1",
        "x": [
          "A",
          "B",
          "C",
          "D"
        ],
        "y": [
          50,
          70,
          90,
          35
        ],
        "type": "scatter",
        "zorder": 1
      },
      {

        "line": {
          "width": 5
        },
        "mode": "lines",
        "name": "x2y2",
        "x": [
          "A",
          "B",
          "C",
          "D"
        ],
        "xaxis": "x2",
        "y": [
          100,
          200,
          150,
          190
        ],
        "yaxis": "y2",
        "type": "scatter",
        "zorder": 2
      },
      {

        "line": {
          "width": 5
        },
        "mode": "lines",
        "name": "x2y1",
        "x": [
          "A",
          "B",
          "C",
          "D"
        ],
        "xaxis": "x2",
        "y": [
          50,
          70,
          90,
          35
        ],
        "type": "scatter",
        "zorder": 3
      },
      {

        "line": {
          "width": 5
        },
        "mode": "lines",
        "name": "x1y2",
        "x": [
          "A",
          "B",
          "C",
          "D"
        ],
        "y": [
          100,
          200,
          150,
          190
        ],
        "yaxis": "y2",
        "type": "scatter",
        "zorder": 4
      }
    ];
var layout = {
      "yaxis": {
        "side": "right",
        "ticklabelposition": "inside top"
      },
      "xaxis2": {
        "overlaying": "x",
        "side": "top"
      },
      "yaxis2": {
        "overlaying": "y",
        "side": "left",
        "ticklabelposition": "inside top"
      }
    };

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

Output

newplot
The traces are in the order (from below to above): x1y1 (blue), x1y2 (red), x2y1 (green), x2y2 (orange).
They follow alphabetical order by subplot name

Expected output:

The traces should be in the order (from below to above): x1y1 (blue), x2y2 (orange), x2y1 (green), x1y2 (red).

@archmoj archmoj added the bug something broken label May 24, 2024
@archmoj archmoj assigned archmoj and unassigned Farkites May 31, 2024
@archmoj
Copy link
Contributor

archmoj commented Jul 23, 2024

Closed by #7032.

@archmoj archmoj closed this as completed Jul 23, 2024
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

2 participants