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

Skip to content

Commit 3783494

Browse files
committed
Added smoke test for Axes.text
1 parent b617bf5 commit 3783494

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,33 @@ def test_streamplot(self):
355355
fig, ax = plt.subplots()
356356
ax.streamplot(...)
357357

358-
@pytest.mark.xfail(reason="Test for text not written yet")
359358
@mpl.style.context("default")
360359
def test_text(self):
361-
fig, ax = plt.subplots()
362-
ax.text(...)
360+
mpl.rcParams["date.converter"] = 'concise'
361+
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, layout="constrained")
362+
363+
limit_value = 10
364+
font_properties = {'family': 'serif', 'size': 12, 'weight': 'bold'}
365+
test_date = datetime.datetime(2023, 10, 1)
366+
367+
x_data = np.array(range(1, limit_value))
368+
y_data = np.array(range(1, limit_value))
369+
370+
x_dates = np.array(
371+
[datetime.datetime(2023, 10, n) for n in range(1, limit_value)]
372+
)
373+
y_dates = np.array(
374+
[datetime.datetime(2023, 10, n) for n in range(1, limit_value)]
375+
)
376+
377+
ax1.plot(x_dates, y_data)
378+
ax1.text(test_date, 5, "Inserted Text", **font_properties)
379+
380+
ax2.plot(x_data, y_dates)
381+
ax2.text(7, test_date, "Inserted Text", **font_properties)
382+
383+
ax3.plot(x_dates, y_dates)
384+
ax3.text(test_date, test_date, "Inserted Text", **font_properties)
363385

364386
@pytest.mark.xfail(reason="Test for tricontour not written yet")
365387
@mpl.style.context("default")

0 commit comments

Comments
 (0)