Skip to content

[sprint] forward keyword args though table #2167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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([])