Skip to content
Closed
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
29 changes: 26 additions & 3 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
import math
import numpy as np

import pytest

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -259,11 +259,34 @@ def test_bxp(self):
ax.xaxis.set_major_formatter(mpl.dates.DateFormatter("%Y-%m-%d"))
ax.set_title('Box plot with datetime data')

@pytest.mark.xfail(reason="Test for clabel not written yet")
@mpl.style.context("default")
def test_clabel(self):
# Sample data for contour plot
dates = [datetime.datetime(2023, 10, 1) + datetime.timedelta(days=i)
for i in range(10)]

x_start, x_end, x_step = -10.0, 5.0, 0.5
y_start, y_end, y_step = 0, 10, 1

x = np.arange(x_start, x_end, x_step)
y = np.arange(y_start, y_end, y_step)

# In this case, Y axis has dates
X, Y = np.meshgrid(x, dates)

# In this case, X axis has dates
#X, Y = np.meshgrid(dates, y)

rows = len(X)
cols = len(X[0])

z1D = np.arange(rows * cols)
Z = z1D.reshape((rows, cols))

fig, ax = plt.subplots()
ax.clabel(...)
CS = ax.contour(X, Y, Z)

ax.clabel(CS, CS.levels, inline=True, fmt=dict(zip(CS.levels, dates)))

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