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

Skip to content

Commit 8ae4b43

Browse files
added test_hist.py to test_datetime.py
1 parent b8b693a commit 8ae4b43

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,19 @@ def test_hexbin(self):
172172

173173
@mpl.style.context("default")
174174
def test_hist(self):
175-
mpl.rcParams["date.converter"] = "concise"
176-
N = 10
177-
fig, (ax1, ax2, ax3) = plt.subplots(
178-
3, 1, layout="constrained", figsize=(6, 10)
179-
)
175+
mpl.rcParams["date.converter"] = 'concise'
176+
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(8, 12), constrained_layout=True)
180177

181-
x = np.array([datetime.datetime(2023, 9, n) for n in range(1, N)])
182-
ax1.hist(x, range(1, N))
183-
ax2.hist(range(1, N), x)
184-
ax3.hist(x, x)
178+
start_date = datetime.datetime(2023, 10, 1)
179+
time_delta = datetime.timedelta(days=1)
180+
181+
values1 = np.random.randint(1, 10, 30)
182+
values2 = np.random.randint(1, 10, 30)
183+
values3 = np.random.randint(1, 10, 30)
184+
185+
ax1.hist([start_date + i * time_delta for i in range(30)],bins=10,weights=values1)
186+
ax2.hist([start_date + i * time_delta for i in range(30)],bins=10,weights=values2)
187+
ax3.hist([start_date + i * time_delta for i in range(30)],bins=10,weights=values3)
185188

186189
@pytest.mark.xfail(reason="Test for hist2d not written yet")
187190
@mpl.style.context("default")

0 commit comments

Comments
 (0)