Skip to content

Commit 6737379

Browse files
fix: modified tick labels to read mpl ticks labels not positions (#498)
* fix: modified tick labels to read mpl ticks labels not positions * ci: update tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent f6c9542 commit 6737379

29 files changed

+11
-3
lines changed

src/mplhep/plot.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,13 @@ def iterable_not_string(arg):
424424
**_kwargs,
425425
)
426426
_e_leg = ax.errorbar(
427-
[], [], yerr=1, xerr=None, color=_s.get_edgecolor(), label=_label, linestyle=_ls
427+
[],
428+
[],
429+
yerr=1,
430+
xerr=None,
431+
color=_s.get_edgecolor(),
432+
label=_label,
433+
linestyle=_ls,
428434
)
429435
return_artists.append(
430436
StairsArtists(
@@ -545,7 +551,7 @@ def iterable_not_string(arg):
545551
)
546552

547553
elif flow == "show" and (underflow > 0.0 or overflow > 0.0):
548-
xticks = ax.get_xticks().tolist()
554+
xticks = [label.get_text() for label in ax.get_xticklabels()]
549555
lw = ax.spines["bottom"].get_linewidth()
550556
_edges = plottables[0].edges
551557
_centers = plottables[0].centers
@@ -556,6 +562,7 @@ def iterable_not_string(arg):
556562
if underflow > 0.0:
557563
xticks[0] = ""
558564
xticks[1] = f"<{flow_bins[2]}"
565+
ax.set_xticks(ax.get_xticks())
559566
ax.set_xticklabels(xticks)
560567

561568
ax.plot(
@@ -582,6 +589,7 @@ def iterable_not_string(arg):
582589
if overflow > 0.0:
583590
xticks[-1] = ""
584591
xticks[-2] = f">{flow_bins[-3]}"
592+
ax.set_xticks(ax.get_xticks())
585593
ax.set_xticklabels(xticks)
586594
ax.plot(
587595
[_edges[-2], _edges[-1]],

tests/baseline/test_hist2dplot.png

-69 Bytes
Loading
-69 Bytes
Loading
-69 Bytes
Loading
-69 Bytes
Loading
-69 Bytes
Loading
-69 Bytes
Loading
Loading
Loading
-69 Bytes
Loading

tests/baseline/test_histplot.png

-69 Bytes
Loading
-69 Bytes
Loading

tests/baseline/test_histplot_flow.png

-537 Bytes
Loading
Loading
-902 Bytes
Loading
-69 Bytes
Loading
-140 Bytes
Loading

tests/baseline/test_histplot_real.png

-134 Bytes
Loading
-69 Bytes
Loading
-69 Bytes
Loading
-69 Bytes
Loading
-967 Bytes
Loading

tests/baseline/test_histplot_w2.png

-69 Bytes
Loading

tests/baseline/test_log.png

-69 Bytes
Loading

tests/baseline/test_onebin_hist.png

-69 Bytes
Loading

tests/baseline/test_simple.png

-102 Bytes
Loading

tests/baseline/test_simple2d.png

-69 Bytes
Loading

tests/baseline/test_simple_xerr.png

-69 Bytes
Loading

tests/test_mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_simple(mock_matplotlib):
5757
approx([]),
5858
yerr=1,
5959
xerr=None,
60-
linestyle='-',
60+
linestyle="-",
6161
color=ax.stairs().get_edgecolor(),
6262
label="X",
6363
)

0 commit comments

Comments
 (0)