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

Skip to content

Add scatter test for datetime units #26882

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 10 commits into from
Oct 18, 2023
22 changes: 19 additions & 3 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,27 @@ def test_quiverkey(self):
fig, ax = plt.subplots()
ax.quiverkey(...)

@pytest.mark.xfail(reason="Test for scatter not written yet")
@mpl.style.context("default")
def test_scatter(self):
fig, ax = plt.subplots()
ax.scatter(...)
mpl.rcParams["date.converter"] = 'concise'
base = datetime.datetime(2005, 2, 1)
dates = [base + datetime.timedelta(hours=(2 * i)) for i in range(10)]
N = len(dates)
np.random.seed(19680801)
y = np.cumsum(np.random.randn(N))
fig, axs = plt.subplots(3, 1, layout='constrained', figsize=(6, 6))
# datetime array on x axis
axs[0].scatter(dates, y)
for label in axs[0].get_xticklabels():
label.set_rotation(40)
label.set_horizontalalignment('right')
# datetime on y axis
axs[1].scatter(y, dates)
# datetime on both x, y axes
axs[2].scatter(dates, dates)
for label in axs[2].get_xticklabels():
label.set_rotation(40)
label.set_horizontalalignment('right')

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