@@ -143,7 +143,7 @@ var gridAttrs = {
143143 values : [ 'bottom' , 'bottom plot' , 'top plot' , 'top' ] ,
144144 dflt : 'bottom plot' ,
145145 role : 'info' ,
146- editType : 'ticks ' ,
146+ editType : 'plot ' ,
147147 description : [
148148 'Sets where the x axis labels and titles go. *bottom* means' ,
149149 'the very bottom of the grid. *bottom plot* is the lowest plot' ,
@@ -155,7 +155,7 @@ var gridAttrs = {
155155 values : [ 'left' , 'left plot' , 'right plot' , 'right' ] ,
156156 dflt : 'left plot' ,
157157 role : 'info' ,
158- editType : 'ticks ' ,
158+ editType : 'plot ' ,
159159 description : [
160160 'Sets where the y axis labels and titles go. *left* means' ,
161161 'the very left edge of the grid. *left plot* is the leftmost plot' ,
@@ -165,15 +165,30 @@ var gridAttrs = {
165165 editType : 'plot'
166166} ;
167167
168+ function getAxes ( layout , grid , axLetter ) {
169+ var gridVal = grid [ axLetter + 'axes' ] ;
170+ var splomVal = Object . keys ( ( layout . _splomAxes || { } ) [ axLetter ] || { } ) ;
171+
172+ if ( Array . isArray ( gridVal ) ) return gridVal ;
173+ if ( splomVal . length ) return splomVal ;
174+ }
175+
168176// the shape of the grid - this needs to be done BEFORE supplyDataDefaults
169177// so that non-subplot traces can place themselves in the grid
170178function sizeDefaults ( layoutIn , layoutOut ) {
171- var gridIn = layoutIn . grid ;
172- if ( ! gridIn ) return ;
179+ var gridIn = layoutIn . grid || { } ;
180+ var xAxes = getAxes ( layoutOut , gridIn , 'x' ) ;
181+ var yAxes = getAxes ( layoutOut , gridIn , 'y' ) ;
182+
183+ if ( ! layoutIn . grid && ! xAxes && ! yAxes ) return ;
173184
174185 var hasSubplotGrid = Array . isArray ( gridIn . subplots ) && Array . isArray ( gridIn . subplots [ 0 ] ) ;
175- var hasXaxes = Array . isArray ( gridIn . xaxes ) ;
176- var hasYaxes = Array . isArray ( gridIn . yaxes ) ;
186+ var hasXaxes = Array . isArray ( xAxes ) ;
187+ var hasYaxes = Array . isArray ( yAxes ) ;
188+ var isSplomGenerated = (
189+ hasXaxes && xAxes !== gridIn . xaxes &&
190+ hasYaxes && yAxes !== gridIn . yaxes
191+ ) ;
177192
178193 var dfltRows , dfltColumns ;
179194
@@ -182,8 +197,8 @@ function sizeDefaults(layoutIn, layoutOut) {
182197 dfltColumns = gridIn . subplots [ 0 ] . length ;
183198 }
184199 else {
185- if ( hasYaxes ) dfltRows = gridIn . yaxes . length ;
186- if ( hasXaxes ) dfltColumns = gridIn . xaxes . length ;
200+ if ( hasYaxes ) dfltRows = yAxes . length ;
201+ if ( hasXaxes ) dfltColumns = xAxes . length ;
187202 }
188203
189204 var gridOut = layoutOut . grid = { } ;
@@ -206,17 +221,26 @@ function sizeDefaults(layoutIn, layoutOut) {
206221 var rowOrder = coerce ( 'roworder' ) ;
207222 var reversed = rowOrder === 'top to bottom' ;
208223
224+ var dfltGapX = hasSubplotGrid ? 0.2 : 0.1 ;
225+ var dfltGapY = hasSubplotGrid ? 0.3 : 0.1 ;
226+
227+ var dfltSideX , dfltSideY ;
228+ if ( isSplomGenerated ) {
229+ dfltSideX = 'bottom' ;
230+ dfltSideY = 'left' ;
231+ }
232+
209233 gridOut . _domains = {
210- x : fillGridPositions ( 'x' , coerce , hasSubplotGrid ? 0.2 : 0.1 , columns ) ,
211- y : fillGridPositions ( 'y' , coerce , hasSubplotGrid ? 0.3 : 0.1 , rows , reversed )
234+ x : fillGridPositions ( 'x' , coerce , dfltGapX , dfltSideX , columns ) ,
235+ y : fillGridPositions ( 'y' , coerce , dfltGapY , dfltSideY , rows , reversed )
212236 } ;
213237}
214238
215239// coerce x or y sizing attributes and return an array of domains for this direction
216- function fillGridPositions ( axLetter , coerce , dfltGap , len , reversed ) {
240+ function fillGridPositions ( axLetter , coerce , dfltGap , dfltSide , len , reversed ) {
217241 var dirGap = coerce ( axLetter + 'gap' , dfltGap ) ;
218242 var domain = coerce ( 'domain.' + axLetter ) ;
219- coerce ( axLetter + 'side' ) ;
243+ coerce ( axLetter + 'side' , dfltSide ) ;
220244
221245 var out = new Array ( len ) ;
222246 var start = domain [ 0 ] ;
@@ -236,7 +260,7 @@ function contentDefaults(layoutIn, layoutOut) {
236260 // make sure we got to the end of handleGridSizing
237261 if ( ! gridOut || ! gridOut . _domains ) return ;
238262
239- var gridIn = layoutIn . grid ;
263+ var gridIn = layoutIn . grid || { } ;
240264 var subplots = layoutOut . _subplots ;
241265 var hasSubplotGrid = gridOut . _hasSubplotGrid ;
242266 var rows = gridOut . rows ;
@@ -282,8 +306,10 @@ function contentDefaults(layoutIn, layoutOut) {
282306 }
283307 }
284308 else {
285- gridOut . xaxes = fillGridAxes ( gridIn . xaxes , subplots . xaxis , columns , axisMap , 'x' ) ;
286- gridOut . yaxes = fillGridAxes ( gridIn . yaxes , subplots . yaxis , rows , axisMap , 'y' ) ;
309+ var xAxes = getAxes ( layoutOut , gridIn , 'x' ) ;
310+ var yAxes = getAxes ( layoutOut , gridIn , 'y' ) ;
311+ gridOut . xaxes = fillGridAxes ( xAxes , subplots . xaxis , columns , axisMap , 'x' ) ;
312+ gridOut . yaxes = fillGridAxes ( yAxes , subplots . yaxis , rows , axisMap , 'y' ) ;
287313 }
288314
289315 var anchors = gridOut . _anchors = { } ;
0 commit comments