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

Skip to content

Added smoke test for Axes.text in test_datetime.py #27142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,33 @@ def test_streamplot(self):
fig, ax = plt.subplots()
ax.streamplot(...)

@pytest.mark.xfail(reason="Test for text not written yet")
@mpl.style.context("default")
def test_text(self):
fig, ax = plt.subplots()
ax.text(...)
mpl.rcParams["date.converter"] = 'concise'
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, layout="constrained")

limit_value = 10
font_properties = {'family': 'serif', 'size': 12, 'weight': 'bold'}
test_date = datetime.datetime(2023, 10, 1)

x_data = np.array(range(1, limit_value))
y_data = np.array(range(1, limit_value))

x_dates = np.array(
[datetime.datetime(2023, 10, n) for n in range(1, limit_value)]
)
y_dates = np.array(
[datetime.datetime(2023, 10, n) for n in range(1, limit_value)]
)

ax1.plot(x_dates, y_data)
ax1.text(test_date, 5, "Inserted Text", **font_properties)

ax2.plot(x_data, y_dates)
ax2.text(7, test_date, "Inserted Text", **font_properties)

ax3.plot(x_dates, y_dates)
ax3.text(test_date, test_date, "Inserted Text", **font_properties)

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