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

Skip to content

Commit 20e05d1

Browse files
author
Matt Terry
committed
added test for table zorder
1 parent cdbba2f commit 20e05d1

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

lib/matplotlib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,7 @@ def tk_window_focus():
12301230
'matplotlib.tests.test_spines',
12311231
'matplotlib.tests.test_streamplot',
12321232
'matplotlib.tests.test_subplots',
1233+
'matplotlib.tests.test_table',
12331234
'matplotlib.tests.test_text',
12341235
'matplotlib.tests.test_ticker',
12351236
'matplotlib.tests.test_tightlayout',

lib/matplotlib/tests/test_table.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import matplotlib.pyplot as plt
2+
import numpy as np
3+
from matplotlib.testing.decorators import image_comparison
4+
5+
6+
@image_comparison(baseline_images=['table_zorder'], extensions=['png'])
7+
def test_zorder():
8+
data = [[ 66386, 174296,],
9+
[ 58230, 381139,]]
10+
11+
colLabels = ('Freeze', 'Wind')
12+
rowLabels = ['%d year' % x for x in (100, 50)]
13+
14+
15+
cellText = []
16+
yoff = np.array([0.0] * len(colLabels))
17+
for row in reversed(data):
18+
yoff += row
19+
cellText.append(['%1.1f' % (x/1000.0) for x in yoff])
20+
21+
t = np.linspace(0, 2*np.pi, 100)
22+
plt.plot(t, np.cos(t), lw=4, zorder=2)
23+
24+
plt.table(cellText=cellText,
25+
rowLabels=rowLabels,
26+
colLabels=colLabels,
27+
loc='center',
28+
zorder=-2,
29+
)
30+
31+
plt.table(cellText=cellText,
32+
rowLabels=rowLabels,
33+
colLabels=colLabels,
34+
loc='upper center',
35+
zorder=4,
36+
)
37+
plt.yticks([])

0 commit comments

Comments
 (0)