@@ -345,9 +345,10 @@ def _make_xticks(self):
345345 xlabels = [lab .get_text () for lab in self .get_xticklabels ()]
346346
347347 xy = np .vstack ((xticks , np .zeros_like (xticks ))).T
348- xticks_axes = self ._ax .transAxes .inverted ().transform (
349- self ._ax .transData .transform (xy )
350- )[:, 0 ]
348+
349+ inv_trans_axes = self ._ax .transAxes .inverted ()
350+ trans_data = self ._ax .transData
351+ xticks_axes = inv_trans_axes .transform (trans_data .transform (xy ))[:, 0 ]
351352
352353 # width = f"calc({self.width}px + 0.5em)"
353354
@@ -380,6 +381,20 @@ def _make_xticks(self):
380381 f"{ html_to_svg (latex_to_html (label ), baseline = 'hanging' )} </text>"
381382 )
382383
384+ minor_ticks = self ._ax .xaxis .get_minorticklocs ()
385+ if len (minor_ticks ) > 0 :
386+ xy = np .vstack ((minor_ticks , np .zeros_like (minor_ticks ))).T
387+ xticks_axes = inv_trans_axes .transform (trans_data .transform (xy ))[:, 0 ]
388+
389+ for tick in xticks_axes :
390+ if tick < 0 or tick > 1.0 :
391+ continue
392+ x = tick * self .width
393+ bottom_string += (
394+ f'<line x1="{ x } " y1="0" x2="{ x } " y2="{ tick_length * 0.7 } " '
395+ 'style="stroke:black;stroke-width:0.5" />'
396+ )
397+
383398 bottom_string += "</svg></div>"
384399 self ._margins ["bottomspine" ].value = bottom_string
385400
@@ -396,16 +411,18 @@ def _make_yticks(self):
396411 ytexts = [lab .get_text () for lab in ylabels ]
397412
398413 xy = np .vstack ((np .zeros_like (yticks ), yticks )).T
399- yticks_axes = self ._ax .transAxes .inverted ().transform (
400- self ._ax .transData .transform (xy )
401- )[:, 1 ]
414+
415+ inv_trans_axes = self ._ax .transAxes .inverted ()
416+ trans_data = self ._ax .transData
417+ yticks_axes = inv_trans_axes .transform (trans_data .transform (xy ))[:, 1 ]
402418
403419 # Predict width of the left margin based on the longest label
404420 # Need to convert to integer to avoid sub-pixel rendering issues
405421 max_length = math .ceil (max (lab .get_tightbbox ().width for lab in ylabels ))
406422 width = f"calc({ max_length } px + { tick_length } px + { label_offset } px)"
407423 width1 = f"calc({ max_length } px + { label_offset } px)"
408424 width2 = f"calc({ max_length } px)"
425+ width3 = f"calc({ max_length } px + { tick_length * 0.3 } px + { label_offset } px)"
409426
410427 left_string = (
411428 f'<svg height="{ self .height } " width="{ width } ">'
@@ -436,6 +453,21 @@ def _make_yticks(self):
436453 f"{ html_to_svg (latex_to_html (label ), baseline = 'middle' )} </text>"
437454 )
438455
456+ minor_ticks = self ._ax .yaxis .get_minorticklocs ()
457+ if len (minor_ticks ) > 0 :
458+ xy = np .vstack ((np .zeros_like (minor_ticks ), minor_ticks )).T
459+ yticks_axes = inv_trans_axes .transform (trans_data .transform (xy ))[:, 1 ]
460+
461+ for tick in yticks_axes :
462+ if tick < 0 or tick > 1.0 :
463+ continue
464+ y = self .height - (tick * self .height )
465+ left_string += (
466+ f'<line x1="{ width } " y1="{ y } " '
467+ f'x2="{ width3 } " y2="{ y } " '
468+ 'style="stroke:black;stroke-width:0.5" />'
469+ )
470+
439471 left_string += "</svg></div>"
440472 self ._margins ["leftspine" ].value = left_string
441473
0 commit comments