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

Skip to content

Added datetime smoke test for Axes.hexbin #27475

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
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
20 changes: 17 additions & 3 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,25 @@ def test_fill_betweenx(self):
ax2.fill_betweenx(y_dates, x_values1, x_values2)
ax3.fill_betweenx(y_dates, x_dates1, x_dates2)

@pytest.mark.xfail(reason="Test for hexbin not written yet")
@mpl.style.context("default")
def test_hexbin(self):
fig, ax = plt.subplots()
ax.hexbin(...)
mpl.rcParams["date.converter"] = 'concise'
np.random.seed(19680801)

dates = np.arange(np.datetime64('2022-01-01'), np.datetime64('2023-12-31'),
np.timedelta64(1, 'D'))
fig, (ax0, ax1, ax2) = plt.subplots(3, 1)
fig.set_size_inches(4, 8)

n = dates.shape[0]
x = np.random.standard_normal(n)
y = np.random.standard_normal(n)
ax0.hexbin(dates, y, marginals=True, gridsize=(10, 6),
extent=[19030, 19680, min(y), max(y)])
ax1.hexbin(x, dates, marginals=True, gridsize=(10, 6),
extent=[min(x), max(x), 19030, 19680])
ax2.hexbin(dates, dates, marginals=True, gridsize=(10, 6),
extent=[19030, 19900, 19030, 19680])
Comment on lines +450 to +454
Copy link
Member

Choose a reason for hiding this comment

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

The extents for a date axis should probably be given in as a datetime (and if that doesn't work, we should probably know that)

These numbers are the internal representation of matplotlib dates (days since mpl.dates.get_epoch(), which defaults to 1970-01-01) but you should be able to set them to use datetimes instead.


@mpl.style.context("default")
def test_hist(self):
Expand Down