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

Skip to content

Commit 1c31b47

Browse files
committed
Merge pull request #2167 from mrterry/table_zorder
[sprint] forward keyword args though table
2 parents 7b53675 + 341dadb commit 1c31b47

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
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/table.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class Table(Artist):
177177
FONTSIZE = 10
178178
AXESPAD = 0.02 # the border between the axes and table edge
179179

180-
def __init__(self, ax, loc=None, bbox=None):
180+
def __init__(self, ax, loc=None, bbox=None, **kwargs):
181181

182182
Artist.__init__(self)
183183

@@ -201,6 +201,7 @@ def __init__(self, ax, loc=None, bbox=None):
201201
self._autoRows = []
202202
self._autoColumns = []
203203
self._autoFontsize = True
204+
self.update(kwargs)
204205

205206
self.set_clip_on(False)
206207

@@ -453,7 +454,8 @@ def table(ax,
453454
cellLoc='right', colWidths=None,
454455
rowLabels=None, rowColours=None, rowLoc='left',
455456
colLabels=None, colColours=None, colLoc='center',
456-
loc='bottom', bbox=None):
457+
loc='bottom', bbox=None,
458+
**kwargs):
457459
"""
458460
TABLE(cellText=None, cellColours=None,
459461
cellLoc='right', colWidths=None,
@@ -517,7 +519,7 @@ def table(ax,
517519
cellColours = ['w' * cols] * rows
518520

519521
# Now create the table
520-
table = Table(ax, loc, bbox)
522+
table = Table(ax, loc, bbox, **kwargs)
521523
height = table._approx_text_height()
522524

523525
# Add the cells

lib/matplotlib/tests/test_table.py

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

0 commit comments

Comments
 (0)