Skip to content

Commit 4dd7a7b

Browse files
committed
fix: update to work with mpl3.8
1 parent 048b2b4 commit 4dd7a7b

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/mplhep/plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,8 @@ def __init__(self, xsizes, ysizes, divider):
10741074
self.div = divider
10751075

10761076
def get_size(self, renderer):
1077-
xrel, xabs = axes_size.AddList(self.xsizes).get_size(renderer)
1078-
yrel, yabs = axes_size.AddList(self.ysizes).get_size(renderer)
1077+
xrel, xabs = sum(self.xsizes, start=axes_size.Fixed(0)).get_size(renderer)
1078+
yrel, yabs = sum(self.ysizes, start=axes_size.Fixed(0)).get_size(renderer)
10791079
bb = Bbox.from_bounds(*self.div.get_position()).transformed(
10801080
self.div._fig.transFigure
10811081
)
3.07 KB
Loading

tests/test_layouts.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from __future__ import annotations
2+
3+
import os
4+
5+
import matplotlib.pyplot as plt
6+
import pytest
7+
8+
os.environ["RUNNING_PYTEST"] = "true"
9+
10+
import mplhep as hep # noqa: E402
11+
12+
"""
13+
To test run:
14+
python pytest -r sa --mpl --mpl-results-path=pytest_results
15+
16+
When adding new tests, run:
17+
python pytest -r sa --mpl --mpl-generate-path=tests/baseline
18+
"""
19+
20+
plt.switch_backend("Agg")
21+
22+
23+
@pytest.mark.mpl_image_compare(style="default", remove_text=True)
24+
def test_square_cbar():
25+
fig, ax = plt.subplots()
26+
ax = hep.make_square_add_cbar(ax=ax)
27+
return fig

0 commit comments

Comments
 (0)