Skip to content

Commit

Permalink
Merge pull request matplotlib#2167 from mrterry/table_zorder
Browse files Browse the repository at this point in the history
[sprint] forward keyword args though table
  • Loading branch information
dmcdougall committed Jun 30, 2013
2 parents 7b53675 + 341dadb commit 1c31b47
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,7 @@ def tk_window_focus():
'matplotlib.tests.test_spines',
'matplotlib.tests.test_streamplot',
'matplotlib.tests.test_subplots',
'matplotlib.tests.test_table',
'matplotlib.tests.test_text',
'matplotlib.tests.test_ticker',
'matplotlib.tests.test_tightlayout',
Expand Down
8 changes: 5 additions & 3 deletions lib/matplotlib/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class Table(Artist):
FONTSIZE = 10
AXESPAD = 0.02 # the border between the axes and table edge

def __init__(self, ax, loc=None, bbox=None):
def __init__(self, ax, loc=None, bbox=None, **kwargs):

Artist.__init__(self)

Expand All @@ -201,6 +201,7 @@ def __init__(self, ax, loc=None, bbox=None):
self._autoRows = []
self._autoColumns = []
self._autoFontsize = True
self.update(kwargs)

self.set_clip_on(False)

Expand Down Expand Up @@ -453,7 +454,8 @@ def table(ax,
cellLoc='right', colWidths=None,
rowLabels=None, rowColours=None, rowLoc='left',
colLabels=None, colColours=None, colLoc='center',
loc='bottom', bbox=None):
loc='bottom', bbox=None,
**kwargs):
"""
TABLE(cellText=None, cellColours=None,
cellLoc='right', colWidths=None,
Expand Down Expand Up @@ -517,7 +519,7 @@ def table(ax,
cellColours = ['w' * cols] * rows

# Now create the table
table = Table(ax, loc, bbox)
table = Table(ax, loc, bbox, **kwargs)
height = table._approx_text_height()

# Add the cells
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions lib/matplotlib/tests/test_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.testing.decorators import image_comparison


@image_comparison(baseline_images=['table_zorder'],
extensions=['png'],
remove_text=True)
def test_zorder():
data = [[ 66386, 174296,],
[ 58230, 381139,]]

colLabels = ('Freeze', 'Wind')
rowLabels = ['%d year' % x for x in (100, 50)]


cellText = []
yoff = np.array([0.0] * len(colLabels))
for row in reversed(data):
yoff += row
cellText.append(['%1.1f' % (x/1000.0) for x in yoff])

t = np.linspace(0, 2*np.pi, 100)
plt.plot(t, np.cos(t), lw=4, zorder=2)

plt.table(cellText=cellText,
rowLabels=rowLabels,
colLabels=colLabels,
loc='center',
zorder=-2,
)

plt.table(cellText=cellText,
rowLabels=rowLabels,
colLabels=colLabels,
loc='upper center',
zorder=4,
)
plt.yticks([])

0 comments on commit 1c31b47

Please sign in to comment.