plotly/plotly.js · error
Too many auto-margin redraws.
Error message
Too many auto-margin redraws.
What it means
Convergence guard in the auto-margin pipeline. When margins are auto (layout.margin has auto sizes), Plotly redraws the plot repeatedly so margin-pushing components (titles, legends, colorbars, ticks) can converge. fullLayout._redrawFromAutoMarginCount tracks these redraws; once the count exceeds the allowed budget (one initial redraw plus a bounded number of loops per margin-push call), Plotly gives up and throws rather than looping forever. Firing indicates margin computations oscillate or never stabilize for this layout.
Source
Thrown at src/plots/plots.js:1855
if(!fullLayout._replotting && (plots.didMarginChange(oldMargins, gs) || needsRedrawForShift(gd))) {
if('_redrawFromAutoMarginCount' in fullLayout) {
fullLayout._redrawFromAutoMarginCount++;
} else {
fullLayout._redrawFromAutoMarginCount = 1;
}
// Always allow at least one redraw and give each margin-push
// call 3 loops to converge. Of course, for most cases this way too many,
// but let's keep things on the safe side until we fix our
// auto-margin pipeline problems:
// https://github.com/plotly/plotly.js/issues/2704
var maxNumberOfRedraws = 3 * (1 + Object.keys(pushMarginIds).length);
if(fullLayout._redrawFromAutoMarginCount < maxNumberOfRedraws) {
return Registry.call('_doPlot', gd);
} else {
fullLayout._size = oldMargins;
Lib.warn('Too many auto-margin redraws.');
}
}
refineTicks(gd);
};
function refineTicks(gd) {
var axList = axisIDs.list(gd, '', true);
[
'_adjustTickLabelsOverflow',
'_hideCounterAxisInsideTickLabels'
].forEach(function(k) {
for(var i = 0; i < axList.length; i++) {
var hideFn = axList[i][k];
if(hideFn) hideFn();
}
});View on GitHub (pinned to 1d090e0b5f)
Solutions
- Set explicit margin values in layout.margin (l, r, t, b) so no auto-margin redraws are needed.
- Simplify or resize components that push margins (long titles, large legends, colorbars) to help convergence.
- Check for custom component modules whose margin-push callbacks oscillate between values.
- Reduce container resize churn that restarts the auto-margin loop.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/plots/plots.js:1855 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of plotly/plotly.js@1d090e0b5f (2026-09-02).
Data as JSON: /api/errors/c974b318417cefe8.
Report an issue: GitHub.