@@ -493,10 +493,11 @@ plots.supplyDefaults = function(gd) {
493493 plots . supplyLayoutGlobalDefaults ( newLayout , newFullLayout ) ;
494494
495495 var missingWidthOrHeight = ( ! newLayout . width || ! newLayout . height ) ,
496- autosize = newLayout . autosize ,
496+ autosize = newFullLayout . autosize ,
497497 autosizable = gd . _context && gd . _context . autosizable ,
498498 initialAutoSize = missingWidthOrHeight && ( autosize || autosizable ) ;
499499 if ( initialAutoSize ) plots . plotAutoSize ( gd , newLayout , newFullLayout ) ;
500+ else if ( missingWidthOrHeight ) plots . sanitizeMargins ( gd ) ;
500501
501502 // for backwards-compatibility with Plotly v1.x.x
502503 if ( ! autosize && missingWidthOrHeight ) {
@@ -778,7 +779,6 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut) {
778779 coerce ( 'margin.pad' ) ;
779780 coerce ( 'margin.autoexpand' ) ;
780781
781- // called in plotAutoSize otherwise
782782 if ( layoutIn . width && layoutIn . height ) plots . sanitizeMargins ( layoutOut ) ;
783783
784784 coerce ( 'paper_bgcolor' ) ;
@@ -847,9 +847,9 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
847847 if ( heightHasChanged || widthHasChanged ) {
848848 if ( widthHasChanged ) fullLayout . width = newWidth ;
849849 if ( heightHasChanged ) fullLayout . height = newHeight ;
850-
851- plots . sanitizeMargins ( fullLayout ) ;
852850 }
851+
852+ plots . sanitizeMargins ( fullLayout ) ;
853853} ;
854854
855855/**
0 commit comments