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

Skip to content

Commit 273a268

Browse files
authored
Added smoke test for Axes.stem (matplotlib#27135)
* Added smoke test for Axes.stem * Updates to include bottom and orientation * Move code to stem function * Remove whitespace * Changed dates * Formatting Fixes
1 parent 461f0b0 commit 273a268

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,33 @@ def test_stairs(self):
591591
fig, ax = plt.subplots()
592592
ax.stairs(...)
593593

594-
@pytest.mark.xfail(reason="Test for stem not written yet")
595594
@mpl.style.context("default")
596595
def test_stem(self):
597-
fig, ax = plt.subplots()
598-
ax.stem(...)
596+
mpl.rcParams["date.converter"] = "concise"
597+
598+
fig, (ax1, ax2, ax3, ax4, ax5, ax6) = plt.subplots(6, 1, layout="constrained")
599+
600+
limit_value = 10
601+
above = datetime.datetime(2023, 9, 18)
602+
below = datetime.datetime(2023, 11, 18)
603+
604+
x_ranges = np.arange(1, limit_value)
605+
y_ranges = np.arange(1, limit_value)
606+
607+
x_dates = np.array(
608+
[datetime.datetime(2023, 10, n) for n in range(1, limit_value)]
609+
)
610+
y_dates = np.array(
611+
[datetime.datetime(2023, 10, n) for n in range(1, limit_value)]
612+
)
613+
614+
ax1.stem(x_dates, y_dates, bottom=above)
615+
ax2.stem(x_dates, y_ranges, bottom=5)
616+
ax3.stem(x_ranges, y_dates, bottom=below)
617+
618+
ax4.stem(x_ranges, y_dates, orientation="horizontal", bottom=above)
619+
ax5.stem(x_dates, y_ranges, orientation="horizontal", bottom=5)
620+
ax6.stem(x_ranges, y_dates, orientation="horizontal", bottom=below)
599621

600622
@mpl.style.context("default")
601623
def test_step(self):

0 commit comments

Comments
 (0)