@@ -2212,28 +2212,34 @@ axes.doTicks = function(gd, axid, skipTitle) {
22122212
22132213 function doAutoMargins ( ) {
22142214 if ( axLetter !== 'x' && axLetter !== 'y' ) { return ; }
2215- var marginPush = 0 ;
2216- if ( ax . automargin ) {
2217- var axisTitleHeight = ( ax . title !== fullLayout . _dfltTitle [ axLetter ] ?
2218- ax . titlefont . size : 0 ) ;
2219- var axisHeight = ( axLetter === 'x' ? ax . _boundingBox . height : ax . _boundingBox . width ) ;
2220- marginPush = axisTitleHeight + axisHeight ;
2221- }
2222-
22232215 var pushKey = ax . _name + '.automargin' ;
2216+ var sideLetter = ax . side [ 0 ] ;
22242217 var existingPush = fullLayout . _pushmargin [ pushKey ] ;
2218+ var pushParams = {
2219+ x : sideLetter === 'r' ? ax . domain [ 1 ] : ax . domain [ 0 ] ,
2220+ y : sideLetter === 't' ? ax . domain [ 1 ] : ax . domain [ 0 ] ,
2221+ r : 0 , l : 0 , t : 0 , b : 0 } ;
2222+
2223+ if ( ! ax . automargin ) {
2224+ if ( existingPush && ! (
2225+ existingPush . r . size === 0 && existingPush . l . size === 0 &&
2226+ existingPush . b . size === 0 && existingPush . t . size === 0 ) ) {
2227+ Plots . autoMargin ( gd , pushKey , pushParams ) ;
2228+ }
2229+ return ;
2230+ }
22252231
2226- if ( ! fullLayout . _replotting ||
2227- ! existingPush || existingPush [ ax . side [ 0 ] ] . size < marginPush ) {
2232+ var axisTitleHeight = ( ax . title !== fullLayout . _dfltTitle [ axLetter ] ?
2233+ ax . titlefont . size : 0 ) ;
2234+ var axisHeight = ( axLetter === 'x' ?
2235+ ax . _boundingBox . height : ax . _boundingBox . width ) ;
2236+ var marginPush = axisTitleHeight + axisHeight ;
22282237
2229- var pushParams = {
2230- x : ax . side [ 0 ] === 'r' ? ax . domain [ 1 ] : ax . domain [ 0 ] ,
2231- y : ax . side [ 0 ] === 't' ? ax . domain [ 1 ] : ax . domain [ 0 ] ,
2232- r : 0 , l : 0 , t : 0 , b : 0 } ;
2233- pushParams [ ax . side [ 0 ] ] = marginPush ;
2238+ if ( ! fullLayout . _replotting ||
2239+ ! existingPush || existingPush [ sideLetter ] . size < marginPush ) {
2240+ pushParams [ sideLetter ] = marginPush ;
22342241 Plots . autoMargin ( gd , pushKey , pushParams ) ;
22352242 }
2236-
22372243 }
22382244
22392245 var done = Lib . syncOrAsync ( [
0 commit comments