@@ -493,10 +493,11 @@ plots.supplyDefaults = function(gd) {
493
493
plots . supplyLayoutGlobalDefaults ( newLayout , newFullLayout ) ;
494
494
495
495
var missingWidthOrHeight = ( ! newLayout . width || ! newLayout . height ) ,
496
- autosize = newLayout . autosize ,
496
+ autosize = newFullLayout . autosize ,
497
497
autosizable = gd . _context && gd . _context . autosizable ,
498
498
initialAutoSize = missingWidthOrHeight && ( autosize || autosizable ) ;
499
499
if ( initialAutoSize ) plots . plotAutoSize ( gd , newLayout , newFullLayout ) ;
500
+ else if ( missingWidthOrHeight ) plots . sanitizeMargins ( gd ) ;
500
501
501
502
// for backwards-compatibility with Plotly v1.x.x
502
503
if ( ! autosize && missingWidthOrHeight ) {
@@ -778,7 +779,6 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut) {
778
779
coerce ( 'margin.pad' ) ;
779
780
coerce ( 'margin.autoexpand' ) ;
780
781
781
- // called in plotAutoSize otherwise
782
782
if ( layoutIn . width && layoutIn . height ) plots . sanitizeMargins ( layoutOut ) ;
783
783
784
784
coerce ( 'paper_bgcolor' ) ;
@@ -847,9 +847,9 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
847
847
if ( heightHasChanged || widthHasChanged ) {
848
848
if ( widthHasChanged ) fullLayout . width = newWidth ;
849
849
if ( heightHasChanged ) fullLayout . height = newHeight ;
850
-
851
- plots . sanitizeMargins ( fullLayout ) ;
852
850
}
851
+
852
+ plots . sanitizeMargins ( fullLayout ) ;
853
853
} ;
854
854
855
855
/**
0 commit comments