-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
More table documentation #12880
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
More table documentation #12880
Conversation
5e497ff
to
f11bb1a
Compare
lib/matplotlib/table.py
Outdated
@@ -180,7 +180,7 @@ def set_text_props(self, **kwargs): | |||
|
|||
class CustomCell(Cell): | |||
""" | |||
A subclass of Cell where the sides may be visibly toggled. | |||
A subclass of `.Cell` with configurable edge visibility. |
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.
A .Cell
subclass with...
f11bb1a
to
9656a4b
Compare
@@ -239,13 +246,7 @@ def get_path(self): | |||
|
|||
class Table(Artist): | |||
""" | |||
Create a table of cells. | |||
|
|||
Table can have (optional) row and column headers. |
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.
Are these points (this line and the following two) not relevant?
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.
-
is technically not true for
Table
. The table is just an arbitrary arrangement of cells. It does not know about headers. The notion of headers is only present intable()
, which chooses to optionally specially handle columns and rows with index 0. -
Is also not true. Each entry in the table is a
Cell
(which seems too obvious to mention).Cell
s areRectangle
s with associatedText
as written in the cell docstring.
I'm not quite sure about 3) either. Essentially the table is just a 2d array of cells, which don't even have to have the same positions or widths. So the concept of rows and columns is more logical than visual. While there's some size related/position functions like _do_cell_alignment
and auto_set_column_width
, I would have expected some set_column_width(col, width)
and set_row_height(row, height)
functions which are clearly not there. Therefore 3) seems an over-statement of the actual capabilities.
lib/matplotlib/table.py
Outdated
---------------- | ||
**kwargs | ||
`.Artist` properties. | ||
|
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.
Minor preference for no empty line at end of docstring (that makes three lines with effectively no content (empty, closing quotes, empty)).
lib/matplotlib/table.py
Outdated
Parameters | ||
---------- | ||
ax : `matplotlib.axes.Axes` | ||
The `~axes.Axes` to plot the table into. |
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.
dot after the tilde?
lib/matplotlib/table.py
Outdated
AXESPAD = 0.02 # the border between the axes and table edge | ||
|
||
AXESPAD = 0.02 | ||
"""The border between the Axes and the table edge.""" |
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.
in what units?
lib/matplotlib/table.py
Outdated
|
||
Returns | ||
------- | ||
`CustomCell`: Automatically created cell | ||
`CustomCell` |
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.
no backquotes needed i think?
lib/matplotlib/table.py
Outdated
This setting does currently only affect newly created cells using | ||
`.add_cell`. | ||
|
||
To change existing cells, you have to set their edges explicitly: |
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.
Use a code block instead?
blablah::
the code
(if you really want to leave this in doctest format (ugh), note that the second line should have a ... prompt, not >>>)
|
||
Returns T/F, {} | ||
""" | ||
# docstring inherited |
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.
Note that this could additionally return e.g. which cell contained the event (in the dict).
edit: there's already a todo for that.
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.
Currently, the behavior is as documented in the parent. I'm just cleaning up the docs within this PR. So the docstring is redundant and can be left out.
lib/matplotlib/table.py
Outdated
@@ -475,17 +514,11 @@ def auto_set_column_width(self, col): | |||
0: the 1st column |
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.
the previous line should read "labeling" (not labling)
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.
Docstring rewritten and explanation of indices removed. (Also it's not true: If there are labels, 0 is the label row/column; if not 0 is the first row/column). This is a (IMHO not carefully chosen implementation detail of table()
which I do not want to discuss in the docstring of Table
.)
lib/matplotlib/table.py
Outdated
As long as auto font size has not been disabled, the value will be | ||
clipped such that the text will still fit into the table cell. | ||
|
||
You can disable this behavior Using `.auto_set_font_size`. |
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.
using (lowercase)
lib/matplotlib/table.py
Outdated
Notes | ||
----- | ||
As long as auto font size has not been disabled, the value will be | ||
clipped such that the text will still fit into the table cell. |
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.
"such that the text fits into the cell" (delete "will still" and "table")
is the fit check only for the horizontal direction? (that's what the end comment suggests) if so, mention it.
lib/matplotlib/table.py
Outdated
@@ -617,7 +662,18 @@ def _update_positions(self, renderer): | |||
self._offset(ox, oy) | |||
|
|||
def get_celld(self): | |||
"""Return a dict of cells in the table.""" | |||
r""" | |||
Return a dict of cells in the table mapping indices *(row, column)* to |
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.
perhaps delete "indices"
lib/matplotlib/table.py
Outdated
loc='bottom', bbox=None, edges='closed') | ||
Add a table to an `~.axes.Axes`. | ||
|
||
You have to specify at least one of *cellText* or *cellColours*. These |
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 have a preference for passive mode ("At least one of cellText or cellColours must be specified").
cellText : 2D list of str, optional | ||
The texts to place into the table cells. | ||
|
||
*Note*: Line breaks in the strings are currently not accounted for and |
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.
Could use
.. note::
Line breaks ...
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.
This is rather a comment than something which should stand out. Therefore I intendedly chose not to use an admonition.
23a9318
to
91f23ca
Compare
@anntzer Thanks for the thorough review. |
lib/matplotlib/table.py
Outdated
|
||
Returns | ||
------- | ||
`CustomCell`: Automatically created cell | ||
cell : `CustomCell` |
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.
still no backquotes needed I think?
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.
lib/matplotlib/table.py
Outdated
---------- | ||
col : int or sequence of ints | ||
The indices of the columns to auto-scale. | ||
|
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.
remove blank line
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.
please self-merge after tests pass
Won't I need a second review? 😄 |
Not for doc changes.... |
PR Summary
Not all of the table API is great, but at least it's documented now.
This PR does only contain docstring changes, but should not be ported back without #12218.