Skip to content

Add datetime test for ax.violin #30384

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 1 commit 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
27 changes: 24 additions & 3 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,11 +810,32 @@ def test_triplot(self):
fig, ax = plt.subplots()
ax.triplot(...)

@pytest.mark.xfail(reason="Test for violin not written yet")
@pytest.mark.parametrize(("orientation"), ["vertical", "horizontal"])
@mpl.style.context("default")
def test_violin(self):
def test_violin(self, orientation):
fig, ax = plt.subplots()
ax.violin(...)
datetimes = [
datetime.datetime(2023, 2, 10),
datetime.datetime(2023, 5, 18),
datetime.datetime(2023, 6, 6)
]
ax.violin(
[
{
'coords': datetimes,
'vals': [0.1, 0.5, 0.2],
'mean': datetimes[1],
'median': datetimes[1],
'min': datetimes[0],
'max': datetimes[-1],
'quantiles': datetimes
}
],
orientation=orientation,
# TODO: It should be possible for positions to be datetimes too
# https://github.com/matplotlib/matplotlib/issues/30417
# positions=[datetime.datetime(2020, 1, 1)]
)

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