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

Skip to content

Commit 677a406

Browse files
committed
Add test_contourf #26864
1 parent d908b4f commit 677a406

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,29 @@ def test_contour(self):
122122
fig, ax = plt.subplots()
123123
ax.contour(...)
124124

125-
@pytest.mark.xfail(reason="Test for contourf not written yet")
126125
@mpl.style.context("default")
127126
def test_contourf(self):
128-
fig, ax = plt.subplots()
129-
ax.contourf(...)
127+
mpl.rcParams["date.converter"] = "concise"
128+
range_threshold = 10
129+
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, layout="constrained")
130+
131+
x_dates = np.array(
132+
[datetime.datetime(2023, 10, delta) for delta in range(1, range_threshold)]
133+
)
134+
y_dates = np.array(
135+
[datetime.datetime(2023, 10, delta) for delta in range(1, range_threshold)]
136+
)
137+
x_ranges = np.array(range(1, range_threshold))
138+
y_ranges = np.array(range(1, range_threshold))
139+
140+
X_dates, Y_dates = np.meshgrid(x_dates, y_dates)
141+
X_ranges, Y_ranges = np.meshgrid(x_ranges, y_ranges)
142+
143+
Z_ranges = np.cos(X_ranges / 4) + np.sin(Y_ranges / 4)
144+
145+
ax1.contourf(X_dates, Y_dates, Z_ranges)
146+
ax2.contourf(X_dates, Y_ranges, Z_ranges)
147+
ax3.contourf(X_ranges, Y_dates, Z_ranges)
130148

131149
@pytest.mark.xfail(reason="Test for csd not written yet")
132150
@mpl.style.context("default")

0 commit comments

Comments
 (0)