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

Skip to content

Added test for tricontour #27545

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

Closed
wants to merge 1 commit into from
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
39 changes: 35 additions & 4 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import matplotlib.pyplot as plt
import matplotlib as mpl

import matplotlib.tri as tri

class TestDatetimePlotting:
@mpl.style.context("default")
Expand Down Expand Up @@ -805,11 +805,42 @@ def test_text(self):
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")
def test_tricontour(self):
fig, ax = plt.subplots()
ax.tricontour(...)

# make unequailly distributed data points:

dates = np.arange(np.datetime64('2022-01-01'), np.datetime64('2022-12-28'),
np.timedelta64(1,'D'))
n = len(dates)
np.random.seed(19680801)
indx = np.array(np.random.random_sample(n//2)*n, dtype='int')
np.random.seed(100)
indy = np.array(np.random.random_sample(n//2)*n, dtype='int')
x = indx - n/2.
y = indy - n/2.
z = x**2 + y**2 - x/4.
levels = np.linspace(z.min(), z.max(), 5)
dates_x = dates[indx]
dates_y = dates[indy]

# plot:
fig, (ax0, ax1, ax2) = plt.subplots(1,3, figsize=(20, 5))
# dates on y axis
ax0.plot(x, dates_y, 'o', markersize=2, color='lightgrey')
ax0.tricontour(x, dates_y, z, levels=levels)
ax0.tick_params('y',labelrotation=45)
# dates on x axis
ax1.plot(dates_x, y, 'o', markersize=2, color='lightgrey')
ax1.tricontour(dates_x, y, z, levels=levels)
ax1.tick_params('x',labelrotation=45)
# dates on x and y axes
ax2.plot(dates_x, dates_y, 'o', markersize=2, color='lightgrey')
ax2.tricontour(dates_x, dates_y, z, levels=levels)
ax2.tick_params(labelrotation=45)

fig.tight_layout()
plt.show()

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