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

Skip to content

Commit a8ba1e9

Browse files
datetime as bins
1 parent c51bebe commit a8ba1e9

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ def test_hexbin(self):
173173
@mpl.style.context("default")
174174
def test_hist(self):
175175
mpl.rcParams["date.converter"] = 'concise'
176-
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True)
177176

178177
start_date = datetime.datetime(2023, 10, 1)
179178
time_delta = datetime.timedelta(days=1)
@@ -182,6 +181,9 @@ def test_hist(self):
182181
values2 = np.random.randint(1, 10, 30)
183182
values3 = np.random.randint(1, 10, 30)
184183

184+
bin_edges = [start_date + i * time_delta for i in range(31)]
185+
186+
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True)
185187
ax1.hist(
186188
[start_date + i * time_delta for i in range(30)],
187189
bins=10,
@@ -198,6 +200,24 @@ def test_hist(self):
198200
weights=values3
199201
)
200202

203+
fig, (ax4, ax5, ax6) = plt.subplots(3, 1, constrained_layout=True)
204+
ax4.hist(
205+
[start_date + i * time_delta for i in range(30)],
206+
bins=bin_edges,
207+
weights=values1
208+
)
209+
ax5.hist(
210+
[start_date + i * time_delta for i in range(30)],
211+
bins=bin_edges,
212+
weights=values2
213+
)
214+
ax6.hist(
215+
[start_date + i * time_delta for i in range(30)],
216+
bins=bin_edges,
217+
edgecolor='black',
218+
weights=values3
219+
)
220+
201221
@pytest.mark.xfail(reason="Test for hist2d not written yet")
202222
@mpl.style.context("default")
203223
def test_hist2d(self):

0 commit comments

Comments
 (0)