@@ -208,46 +208,46 @@ exports.lsInner = function(gd) {
208208 var ylw = Drawing . crispRound ( gd , ya . linewidth , 1 ) ;
209209
210210 /*
211- * x lines get longer where they meet y lines, to make a crisp corner
212- * free x lines are not excluded - they don't necessarily *meet* the
213- * y lines, but it still looks good if the x line reaches to the ends
214- * of the y lines, especially in the case of a free axis parallel to
215- * an anchored axis, like this:
211+ * x lines get longer where they meet y lines, to make a crisp corner.
212+ * The x lines get the padding (margin.pad) plus the y line width to
213+ * fill up the corner nicely. Free x lines are excluded - they always
214+ * span exactly the data area of the plot
216215 *
216+ * | XXXXX
217+ * | XXXXX
217218 * |
218- * |
219- * +-----
220- * x1
221- * ------
222- * ^ x2
219+ * +------
220+ * x1
221+ * -----
222+ * x2
223223 */
224- var xLinesXLeft = - pad - findCounterAxisLineWidth ( gd , xa , ylw , showLeft , 'left' , axList ) ;
225- var xLinesXRight = xa . _length + pad + findCounterAxisLineWidth ( gd , xa , ylw , showRight , 'right' , axList ) ;
224+ var leftYLineWidth = findCounterAxisLineWidth ( gd , xa , ylw , showLeft , 'left' , axList ) ;
225+ var xLinesXLeft = ( ! xIsFree && leftYLineWidth ) ?
226+ ( - pad - leftYLineWidth ) : 0 ;
227+ var rightYLineWidth = findCounterAxisLineWidth ( gd , xa , ylw , showRight , 'right' , axList ) ;
228+ var xLinesXRight = xa . _length + ( ( ! xIsFree && rightYLineWidth ) ?
229+ ( pad + rightYLineWidth ) : 0 ) ;
226230 var xLinesYFree = gs . h * ( 1 - ( xa . position || 0 ) ) + ( ( xlw / 2 ) % 1 ) ;
227231 var xLinesYBottom = ya . _length + pad + xlw / 2 ;
228232 var xLinesYTop = - pad - xlw / 2 ;
229233
230234 /*
231- * y lines do not get longer when they meet x axes, because the
232- * x axis already filled that space and we don't want to double-fill.
233- * BUT they get longer if they're free axes, for the same reason as
234- * we do not exclude x axes:
235- *
236- * | |
237- * y2| y1|
238- * | |
239- * >| +-----
235+ * y lines that meet x axes get longer only by margin.pad, because
236+ * the x axes fill in the corner space. Free y axes, like free x axes,
237+ * always span exactly the data area of the plot
240238 *
241- * arguably if the free y axis is over top of the anchored x axis,
242- * we don't want to do this... but that's a weird edge case, doesn't
243- * seem worth adding a lot of complexity for.
239+ * | | XXXX
240+ * y2| y1| XXXX
241+ * | | XXXX
242+ * |
243+ * +-----
244244 */
245- var yLinesYBottom = ya . _length + pad + ( yIsFree ?
246- findCounterAxisLineWidth ( gd , ya , xlw , showBottom , 'bottom' , axList ) :
247- 0 ) ;
248- var yLinesYTop = - pad - ( yIsFree ?
249- findCounterAxisLineWidth ( gd , ya , xlw , showTop , 'top' , axList ) :
250- 0 ) ;
245+ var connectYBottom = ! yIsFree && findCounterAxisLineWidth (
246+ gd , ya , xlw , showBottom , 'bottom' , axList ) ;
247+ var yLinesYBottom = ya . _length + ( connectYBottom ? pad : 0 ) ;
248+ var connectYTop = ! yIsFree && findCounterAxisLineWidth (
249+ gd , ya , xlw , showTop , 'top' , axList ) ;
250+ var yLinesYTop = connectYTop ? - pad : 0 ;
251251 var yLinesXFree = gs . w * ( ya . position || 0 ) + ( ( ylw / 2 ) % 1 ) ;
252252 var yLinesXLeft = - pad - ylw / 2 ;
253253 var yLinesXRight = xa . _length + pad + ylw / 2 ;
0 commit comments