Skip to content

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

Merged
merged 1 commit into from
Dec 6, 2018
Merged

More table documentation #12880

merged 1 commit into from
Dec 6, 2018

Conversation

timhoffm
Copy link
Member

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.

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A .Cell subclass with...

@@ -239,13 +246,7 @@ def get_path(self):

class Table(Artist):
"""
Create a table of cells.

Table can have (optional) row and column headers.
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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 in table(), which chooses to optionally specially handle columns and rows with index 0.

  2. Is also not true. Each entry in the table is a Cell (which seems too obvious to mention). Cells are Rectangles with associated Text 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.

----------------
**kwargs
`.Artist` properties.

Copy link
Contributor

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)).

Parameters
----------
ax : `matplotlib.axes.Axes`
The `~axes.Axes` to plot the table into.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dot after the tilde?

AXESPAD = 0.02 # the border between the axes and table edge

AXESPAD = 0.02
"""The border between the Axes and the table edge."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in what units?


Returns
-------
`CustomCell`: Automatically created cell
`CustomCell`
Copy link
Contributor

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?

This setting does currently only affect newly created cells using
`.add_cell`.

To change existing cells, you have to set their edges explicitly:
Copy link
Contributor

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
Copy link
Contributor

@anntzer anntzer Dec 4, 2018

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.

Copy link
Member Author

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.

@@ -475,17 +514,11 @@ def auto_set_column_width(self, col):
0: the 1st column
Copy link
Contributor

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)

Copy link
Member Author

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.)

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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using (lowercase)

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.
Copy link
Contributor

@anntzer anntzer Dec 4, 2018

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.

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps delete "indices"

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
Copy link
Contributor

@anntzer anntzer Dec 4, 2018

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
Copy link
Contributor

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 ...

Copy link
Member Author

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.

@anntzer anntzer mentioned this pull request Dec 4, 2018
6 tasks
@timhoffm timhoffm force-pushed the doc-table-2 branch 2 times, most recently from 23a9318 to 91f23ca Compare December 5, 2018 22:09
@timhoffm
Copy link
Member Author

timhoffm commented Dec 5, 2018

@anntzer Thanks for the thorough review.


Returns
-------
`CustomCell`: Automatically created cell
cell : `CustomCell`
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the backquotes are intended to link to CustomCell:
image

I've added a leading .

----------
col : int or sequence of ints
The indices of the columns to auto-scale.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove blank line

Copy link
Contributor

@anntzer anntzer left a 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

@timhoffm
Copy link
Member Author

timhoffm commented Dec 6, 2018

Won't I need a second review? 😄

@jklymak
Copy link
Member

jklymak commented Dec 6, 2018

Not for doc changes....

@jklymak jklymak merged commit 9c56881 into matplotlib:master Dec 6, 2018
@timhoffm timhoffm deleted the doc-table-2 branch December 6, 2018 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants