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

Appearance settings

Commit fb0802d

Browse filesBrowse files
committed
Make suggested modifications to test_barh in test_datetime.py
1 parent 18358eb commit fb0802d
Copy full SHA for fb0802d

File tree

Expand file treeCollapse file tree

1 file changed

+15
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-11
lines changed

‎lib/matplotlib/tests/test_datetime.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_datetime.py
+15-11Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,21 @@ def test_barbs(self):
7777
@mpl.style.context("default")
7878
def test_barh(self):
7979
mpl.rcParams["date.converter"] = 'concise'
80-
N = 14
81-
base = datetime.datetime(1970, 1, 1)
82-
indices = np.arange(N)
83-
dates = [base + datetime.timedelta(days=(7 * i)) for i in range(N)]
84-
widths = [datetime.timedelta(days=(7*i)) for i in range(N)]
85-
fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, layout='constrained')
86-
error = np.random.rand(N)
87-
ax1.barh(indices, dates, xerr=error)
88-
ax2.barh(dates, indices)
89-
ax3.barh(dates, dates)
90-
ax4.barh(indices, width=widths, left=base)
80+
fig, (ax1, ax2) = plt.subplots(2, 1, layout='constrained')
81+
birth_date = np.array([datetime.datetime(2020, 4, 10),
82+
datetime.datetime(2020, 5, 30),
83+
datetime.datetime(2020, 10, 12),
84+
datetime.datetime(2020, 11, 15)])
85+
year_start = datetime.datetime(2020, 1, 1)
86+
year_end = datetime.datetime(2020, 12, 31)
87+
age = [21, 53, 20, 24]
88+
ax1.set_xlabel('Age')
89+
ax1.set_ylabel('Birth Date')
90+
ax1.barh(birth_date, width=age, height=datetime.timedelta(days=10))
91+
ax2.set_xlim(left=year_start, right=year_end)
92+
ax2.set_xlabel('Birth Date')
93+
ax2.set_ylabel('Order of Birth Dates')
94+
ax2.barh(np.arange(4), birth_date-year_start, left=year_start)
9195

9296
@pytest.mark.xfail(reason="Test for boxplot not written yet")
9397
@mpl.style.context("default")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.