Skip to content

Commit 32fae3d

Browse files
committed
fix left axis hiding issue
1 parent bae13a2 commit 32fae3d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/matplotgl/axes.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22

3+
import math
4+
35
import ipywidgets as ipw
46
import numpy as np
57
import pythreejs as p3
@@ -347,6 +349,8 @@ def _make_xticks(self):
347349
self._ax.transData.transform(xy)
348350
)[:, 0]
349351

352+
# width = f"calc({self.width}px + 0.5em)"
353+
350354
bottom_string = (
351355
f'<svg height="calc(1.2em + {tick_length}px + {label_offset}px)" '
352356
f'width="{self.width}"><line x1="0" y1="0" x2="{self.width}" y2="0" '
@@ -395,16 +399,21 @@ def _make_yticks(self):
395399
)[:, 1]
396400

397401
# Predict width of the left margin based on the longest label
398-
max_length = max(lab.get_tightbbox().width for lab in ylabels)
402+
# Need to convert to integer to avoid sub-pixel rendering issues
403+
max_length = math.ceil(max(lab.get_tightbbox().width for lab in ylabels))
399404
width = f"calc({max_length}px + {tick_length}px + {label_offset}px)"
400405
width1 = f"calc({max_length}px + {label_offset}px)"
401406
width2 = f"calc({max_length}px)"
407+
# width3 = f"calc({max_length}px + {tick_length}px + {label_offset}px - 1px)"
402408

403409
left_string = (
404410
f'<svg height="{self.height}" width="{width}">'
405411
f'<line x1="{width}" y1="0" '
406412
f'x2="{width}" y2="{self.height}" '
407413
f'style="stroke:black;stroke-width:{self._spine_linewidth}" />'
414+
# f'<line x1="{width3}" y1="0" '
415+
# f'x2="{width3}" y2="{self.height}" '
416+
# f'style="stroke:black;stroke-width:{self._spine_linewidth}" />'
408417
)
409418

410419
self._margins["rightspine"].value = (

0 commit comments

Comments
 (0)