Skip to content

Missing (gap) Options for heatmap #383

Closed

Description

@atticus-sullivan

Hi,

I really love I can generate plotly plots with rust. Working with heatmaps recently, I discovered plotly.rs is missing the xgap and ygap parameters (maybe other parameters as well). Can we have setters/setters for these parameters in plotly.rs?

Also is there some sort of workaround how I can (temporarily) set such values as long plotly.rs does not support them?

References:

Activity

  1. atticus-sullivan commented on Feb 9, 2026

    @atticus-sullivan
    ContributorAuthor

    Also it seems like for using the text or hovertext parameters in conjunction with the heatmap, it needs to have the same dimensions as the z value.

    I made a small example demonstrating how the resulting js needs to look like (demonstrating both, the {x,y}gap and the {hover,}text parameter:

        Plotly.newPlot("TCNx0eInClUJYtdkzJ1A", {
      "data": [
        {
          "xgap": 2,
          "ygap": 1,
          "type": "heatmap",
          "hoverinfo": "text",
          "text": [
            [
              "a",
              "b",
              "c",
              "d",
            ],
            [
              "e",
              "f",
              "g",
              "h"
            ]
          ],
          "x": [
            0.0,
            1.0,
            2.0,
            3.0,
          ],
          "y": [
            "abcd",
            "efgh"
          ],
          "z": [
            [
              0.0,
              1.0,
              2.0,
              3.0,
            ],
            [
              0.0,
              2.0,
              1.0,
              2.0,
            ]
          ]
        }
      ],
    });

    with

    <script src="https://cdn.plot.ly/plotly-3.3.1.min.js"></script>
    <body>
      <div id="TCNx0eInClUJYtdkzJ1A" class="plotly-graph-div" style="height:100%; width:100%;"></div>
    </body>

    If the text parameter is simply a Vec<String> as it is basically enforced right now, the hover is simply not shown (I had to test this myself as I found the plotly docs not very readable on this one though).

  2. andrei-ng commented on Feb 11, 2026

    @andrei-ng
    Collaborator

    Hi,

    I really love I can generate plotly plots with rust. Working with heatmaps recently, I discovered plotly.rs is missing the xgap and ygap parameters (maybe other parameters as well). Can we have setters/setters for these parameters in plotly.rs?

    Also is there some sort of workaround how I can (temporarily) set such values as long plotly.rs does not support them?

    References:

    Hi,

    It is straightforward to add. You just need to add the two fields to the struct definition in

    z: Option<Vec<Z>>,

    Once you add the members/fields the macros will generate the setters .

    Feel free to open a PR with the addition and I will merge it.

  3. andrei-ng commented on Feb 11, 2026

    @andrei-ng
    Collaborator

    Also it seems like for using the text or hovertext parameters in conjunction with the heatmap, it needs to have the same dimensions as the z value.

    I made a small example demonstrating how the resulting js needs to look like (demonstrating both, the {x,y}gap and the {hover,}text parameter:

    Plotly.newPlot("TCNx0eInClUJYtdkzJ1A", {
    

    "data": [
    {
    "xgap": 2,
    "ygap": 1,
    "type": "heatmap",
    "hoverinfo": "text",
    "text": [
    [
    "a",
    "b",
    "c",
    "d",
    ],
    [
    "e",
    "f",
    "g",
    "h"
    ]
    ],
    "x": [
    0.0,
    1.0,
    2.0,
    3.0,
    ],
    "y": [
    "abcd",
    "efgh"
    ],
    "z": [
    [
    0.0,
    1.0,
    2.0,
    3.0,
    ],
    [
    0.0,
    2.0,
    1.0,
    2.0,
    ]
    ]
    }
    ],
    });
    with

    <script src="https://cdn.plot.ly/plotly-3.3.1.min.js"></script>
    If the `text` parameter is simply a `Vec` as it is basically enforced right now, the hover is simply not shown (I had to test this myself as I found the plotly docs not very readable on this one though).

    Thanks for the example. This seems to be a bug. I will need to have a closer look at it. If it is a bug, I will convert your comment into a new issue.

  4. atticus-sullivan commented on Feb 11, 2026

    @atticus-sullivan
    ContributorAuthor

    Thanks for the reply 👍 . And yes sorry for opening two issues in one. Feel free to open the second issue in case you can verify the bug (also please ping me there so I get a notification).

  5. andrei-ng commented on Feb 12, 2026

    @andrei-ng
    Collaborator

    xgap and ygap added in #385

    @atticus-sullivan For the second part I opened a separate issue #386

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions