Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b77763

Browse files
authored
Merge pull request matplotlib#27033 from kots14/axes-bar-unit-test-for-issue-26864
Add test_bar in test_datetime
2 parents f3585ef + e27da80 commit 4b77763

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,26 @@ def test_axvspan(self):
134134
ax3.set_xlabel('Date')
135135
ax3.set_ylabel('Date')
136136

137-
@pytest.mark.xfail(reason="Test for bar not written yet")
138137
@mpl.style.context("default")
139138
def test_bar(self):
140-
fig, ax = plt.subplots()
141-
ax.bar(...)
139+
mpl.rcParams["date.converter"] = "concise"
140+
141+
fig, (ax1, ax2) = plt.subplots(2, 1, layout="constrained")
142+
143+
x_dates = np.array(
144+
[
145+
datetime.datetime(2020, 6, 30),
146+
datetime.datetime(2020, 7, 22),
147+
datetime.datetime(2020, 8, 3),
148+
datetime.datetime(2020, 9, 14),
149+
],
150+
dtype=np.datetime64,
151+
)
152+
x_ranges = [8800, 2600, 8500, 7400]
153+
154+
x = np.datetime64(datetime.datetime(2020, 6, 1))
155+
ax1.bar(x_dates, x_ranges, width=np.timedelta64(4, "D"))
156+
ax2.bar(np.arange(4), x_dates - x, bottom=x)
142157

143158
@pytest.mark.xfail(reason="Test for bar_label not written yet")
144159
@mpl.style.context("default")

0 commit comments

Comments
 (0)