-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Implementation of Issue #4044. Added ScientificTable and ScientificCell subclasses. #4259
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
Changes from all commits
e893f58
fffc63f
d2b8b27
d8a42dd
d2c3158
4542ee7
39cecdc
7b32f5e
6169f0c
b68c05f
9337be7
ac6f471
842a5c4
17576d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Updated Table and to control edge visibility | ||
-------------------------------------------- | ||
Added the ability to toggle the visibility of lines in Tables. | ||
Functionality added to the table() factory function under the keyword argument "edges". | ||
Values can be the strings "open", "closed", "horizontal", "vertical" or combinations of the letters "L", "R", "T", "B" which represent left, right, top, and bottom respectively. | ||
|
||
Example: | ||
table(..., edges="open") # No line visible | ||
table(..., edges="closed") # All lines visible | ||
table(..., edges="horizontal") # Only top and bottom lines visible | ||
table(..., edges="LT") # Only left and top lines visible. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,10 @@ | |
import numpy as np | ||
from matplotlib.testing.decorators import image_comparison | ||
|
||
from matplotlib.table import CustomCell | ||
from matplotlib.path import Path | ||
from nose.tools import assert_equal | ||
|
||
|
||
@image_comparison(baseline_images=['table_zorder'], | ||
extensions=['png'], | ||
|
@@ -79,3 +83,41 @@ def test_label_colours(): | |
colColours=colours, | ||
colLabels=['Header'] * dim, | ||
loc='best') | ||
|
||
|
||
@image_comparison(baseline_images=['table_cell_manipulation'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been addressed. |
||
extensions=['png'], remove_text=True) | ||
def test_diff_cell_table(): | ||
cells = ('horizontal', 'vertical', 'open', 'closed', 'T', 'R', 'B', 'L') | ||
cellText = [['1'] * len(cells)] * 2 | ||
colWidths = [0.1] * len(cells) | ||
|
||
_, axes = plt.subplots(nrows=len(cells), figsize=(4, len(cells)+1)) | ||
for ax, cell in zip(axes, cells): | ||
ax.table( | ||
colWidths=colWidths, | ||
cellText=cellText, | ||
loc='center', | ||
edges=cell, | ||
) | ||
ax.axis('off') | ||
plt.tight_layout() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't essential to the test, is it? |
||
|
||
|
||
def test_customcell(): | ||
types = ('horizontal', 'vertical', 'open', 'closed', 'T', 'R', 'B', 'L') | ||
codes = ( | ||
(Path.MOVETO, Path.LINETO, Path.MOVETO, Path.LINETO, Path.MOVETO), | ||
(Path.MOVETO, Path.MOVETO, Path.LINETO, Path.MOVETO, Path.LINETO), | ||
(Path.MOVETO, Path.MOVETO, Path.MOVETO, Path.MOVETO, Path.MOVETO), | ||
(Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY), | ||
(Path.MOVETO, Path.MOVETO, Path.MOVETO, Path.LINETO, Path.MOVETO), | ||
(Path.MOVETO, Path.MOVETO, Path.LINETO, Path.MOVETO, Path.MOVETO), | ||
(Path.MOVETO, Path.LINETO, Path.MOVETO, Path.MOVETO, Path.MOVETO), | ||
(Path.MOVETO, Path.MOVETO, Path.MOVETO, Path.MOVETO, Path.LINETO), | ||
) | ||
|
||
for t, c in zip(types, codes): | ||
cell = CustomCell((0, 0), visible_edges=t, width=1, height=1) | ||
code = tuple(s for _, s in cell.get_path().iter_segments()) | ||
assert_equal(c, code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trim the extra white space please.
We much not have pep8 compliance on the rest of this file or the test would be failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tacaswell do you mean the extra whitespace inside the _edge_aliases dictionary? I can't see any other whitespace and yeah pep8 isn't failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect pep8 to require
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tacaswell afaik spaces are allowed after colons inside of dictionaries.
Nothing against it is mentioned in the PEP 8 style guide: https://www.python.org/dev/peps/pep-0008/
And running pep8 on a minimal example and people on SO seem to confirm: http://stackoverflow.com/questions/13497793/python-alignment-of-assignments-style
I'm also at PyCon right now, I could ask people here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, learn something every day.