Skip to content

Commit ccc16e1

Browse files
committed
fix for labels
1 parent 19dd43b commit ccc16e1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/tikzplotlib/_axes.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,19 +570,25 @@ def _get_ticks(data, xy, ticks, ticklabels):
570570
label = ticklabel.get_text()
571571
if "," in label:
572572
label = "{" + label + "}"
573+
573574
if ticklabel.get_visible():
574-
label = _common_texification(label)
575-
pgfplots_ticklabels.append(label)
575+
pgfplots_ticklabels.append(_common_texification(label))
576576
else:
577577
is_label_required = True
578+
578579
# Check if the label is necessary. If one of the labels is, then all of them
579580
# must appear in the TikZ plot.
580581
if label:
581582
try:
582583
label_float = float(label.replace("\N{MINUS SIGN}", "-"))
583-
is_label_required = is_label_required or (label and label_float != tick)
584584
except ValueError:
585585
is_label_required = True
586+
else:
587+
is_label_required = is_label_required or (
588+
label and abs(label_float - tick) > 1.0e-10 + 1.0e-10 * abs(tick)
589+
)
590+
print(label_float, tick, label_float - tick, is_label_required)
591+
586592
# note: ticks may be present even if labels are not, keep them for grid lines
587593
for tick in ticks:
588594
pgfplots_ticks.append(tick)

tests/test_fillstyle_reference.tex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
x grid style={white!69.019608!black},
99
xmin=-0.05, xmax=1.05,
1010
xtick style={color=black},
11-
xtick={-0.2,0,0.2,0.4,0.6,0.8,1,1.2},
12-
xticklabels={−0.2,0.0,0.2,0.4,0.6,0.8,1.0,1.2},
1311
y grid style={white!69.019608!black},
1412
ymin=-0.45, ymax=9.45,
1513
ytick style={color=black}

0 commit comments

Comments
 (0)