Skip to content
Open
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
35 changes: 32 additions & 3 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,40 @@ def test_tricontourf(self):
fig, ax = plt.subplots()
ax.tricontourf(...)

@pytest.mark.xfail(reason="Test for tripcolor not written yet")
@mpl.style.context("default")
def test_tripcolor(self):
fig, ax = plt.subplots()
ax.tripcolor(...)
mpl.rcParams["date.converter"] = 'concise'
plt.style.use('_mpl-gallery-nogrid')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
plt.style.use('_mpl-gallery-nogrid')

The gallery-style is not used for tests (and is already set by @mpl.style.context("default")).


fig, (ax, ax1, ax2) = plt.subplots(3, 1, figsize=(6, 4))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fig, (ax, ax1, ax2) = plt.subplots(3, 1, figsize=(6, 4))
fig, (ax, ax1, ax2) = plt.subplots(3, 1, figsize=(6, 4), layout='constrained')

dates = np.arange(np.datetime64('2022-01-01'), np.datetime64('2023-12-31'),
np.timedelta64(1, 'D'))
n = 256
np.random.seed(19680801)
xz = np.random.uniform(-3, 3, n)
yz = np.random.uniform(-3, 3, n)
zz = (1 - xz / 2 + xz ** 5 + yz ** 3) * np.exp(-xz ** 2 - yz ** 2)

# Randomly sample n dates for x-axis and different y values than above
x_rand_dates = np.random.choice(dates, n, replace=False)
y = np.random.uniform(-3, 3, n)

# Randomly sample n dates for the y-axis and different x values than above
x = np.random.uniform(-3, 3, n)
y_rand_dates = np.random.choice(dates, n, replace=False)

# plot:
ax.plot(x_rand_dates, y, 'o', markersize=2, color='grey')
ax.tripcolor(x_rand_dates, y, zz)
ax1.plot(x, y_rand_dates, 'o', markersize=2, color='grey')
ax1.tripcolor(x, y_rand_dates, zz)
ax2.plot(x_rand_dates, y_rand_dates, 'o', markersize=2, color='grey')
ax2.tripcolor(x_rand_dates, y_rand_dates, zz)
ax.set(xlim=(min(x_rand_dates), max(x_rand_dates)), ylim=(min(y), max(y)))
ax1.set(xlim=(min(x), max(x)), ylim=(min(y_rand_dates), max(y_rand_dates)))
ax2.set(xlim=(min(x_rand_dates), max(x_rand_dates)), ylim=(min(y_rand_dates),
max(y_rand_dates)))
fig.tight_layout()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fig.tight_layout()


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