Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

test_tripcolor (Issue #26864) plots with datetime on x-axis only , y-axis only, and both x- and y-axis#27491

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
bikegeek wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
frombikegeek:issue-26864-test-tripcolor
Open
Changes fromall 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 deletionslib/matplotlib/tests/test_datetime.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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
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")).

jklymak reacted with thumbs up emoji

fig, (ax, ax1, ax2) = plt.subplots(3, 1, figsize=(6, 4))
Copy link
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
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

[8]ページ先頭

©2009-2025 Movatter.jp