plotly/plotly.js · warning

node.pad was reduced to <sankey.nodePadding()> to fit withi

Error message

node.pad was reduced to <sankey.nodePadding()>  to fit within the figure.

What it means

After running the d3-sankey layout in src/traces/sankey/render.js:94, Plotly compares the padding d3 actually used (sankey.nodePadding()) with the requested node.pad. When the figure is too short for all nodes at the requested padding, d3 shrinks the padding to fit and Plotly warns that node.pad was reduced.

Source

Thrown at src/traces/sankey/render.js:94

    function applyInputSort(type) {
        if (trace[type].sort === 'input') {
            if (circular) {
                Lib.warn(
                    `Circular Sankey diagrams do not support the "input" ${type}.sort mode; falling back to the default sort.`
                );
            } else {
                // Passing null maintains the input order
                sankey[`${type}Sort`](null);
            }
        }
    }
    applyInputSort('link');
    applyInputSort('node');

    var graph = sankey();

    if(sankey.nodePadding() < nodePad) {
        Lib.warn('node.pad was reduced to ', sankey.nodePadding(), ' to fit within the figure.');
    }

    // Counters for nested loops
    var i, j, k;

    // Create transient nodes for animations
    for(var nodePointNumber in calcData._groupLookup) {
        var groupIndex = parseInt(calcData._groupLookup[nodePointNumber]);

        // Find node representing groupIndex
        var groupingNode;

        for(i = 0; i < graph.nodes.length; i++) {
            if(graph.nodes[i].pointNumber === groupIndex) {
                groupingNode = graph.nodes[i];
                break;
            }
        }

View on GitHub (pinned to 1d090e0b5f)

Solutions

  1. Increase the figure height (layout.height) so the requested node.pad fits.
  2. Reduce layout.node.pad to a value the figure can accommodate.
  3. Reduce the number of nodes or consolidate links so less vertical space is needed.

Example fix

// before
var layout = { height: 300, node: { pad: 20 } }; // many nodes
// after
var layout = { height: 700, node: { pad: 20 } };
Defensive patterns

Strategy: validation

Validate before calling

// rough check: needed height ~ nNodes*(nodeThickness) + (nNodes+1)*pad
const est = nodes.length * 20 + (nodes.length + 1) * layout.node.pad;
if (est > layout.height) console.warn('Increase layout.height above ~' + est + ' or lower node.pad');

Prevention

When it happens

Trigger: Large node.pad (default 20/8 px) combined with many nodes and/or a small figure height, so node heights plus requested padding exceed the plot height.

Common situations: Sankeys with dozens of nodes in a 400px-tall figure; embedding sankeys in small dashboard tiles; increasing node.pad or node.thickness without resizing the container.

Related errors


AI-assisted analysis of plotly/plotly.js@1d090e0b5f (2026-09-02). Data as JSON: /api/errors/aa50eb873c2a192f. Report an issue: GitHub.