Skip to content

Minor Bug on table.py #5350

Closed
Closed

Description

@jcolonese

Hello,

I'm a regular user of matplotlib in windows but not so into hard programming. When trying to draw a colored table with uneven shape (1 row and 10 columns) and just filled colors in each cell, I've found some minor problems. I was using pyplot.table without setting cellText. I've noticed that the error messages on master are quite more clear than the one in my version, but this particular issue is still on there.
When someone does not explicit set cellText contents, the function gets the table shape by cellColours, but positions of rows and cols variables are changed in line 563 (from master). It should be just like in line 580, I think.

Hope that helped!

Cheers

Juan

def table(ax,
          cellText=None, cellColours=None,
          cellLoc='right', colWidths=None,
          rowLabels=None, rowColours=None, rowLoc='left',
          colLabels=None, colColours=None, colLoc='center',
          loc='bottom', bbox=None, edges='closed',
          **kwargs):
    """
    TABLE(cellText=None, cellColours=None,
          cellLoc='right', colWidths=None,
          rowLabels=None, rowColours=None, rowLoc='left',
          colLabels=None, colColours=None, colLoc='center',
          loc='bottom', bbox=None, edges='closed')
    Factory function to generate a Table instance.
    Thanks to John Gill for providing the class and table.
    """

    # Check we have some cellText
    if cellText is None:
        # assume just colours are needed
        rows = len(cellColours)
        cols = len(cellColours[0])
       cellText = [[''] * rows] * cols  #jcolonese: I think it should be 
                                                   #" cellText = [[''] * cols] * rows "

    rows = len(cellText)
    cols = len(cellText[0])
    for row in cellText:
        if len(row) != cols:
            msg = "Each row in 'cellText' must have {0} columns"
            raise ValueError(msg.format(cols))

    if cellColours is not None:
        if len(cellColours) != rows:
            raise ValueError("'cellColours' must have {0} rows".format(rows))
        for row in cellColours:
            if len(row) != cols:
                msg = "Each row in 'cellColours' must have {0} columns"
                raise ValueError(msg.format(cols))
    else:
        cellColours = ['w' * cols] * rows #jcolonese: exactly like here

Activity

  1. added this to the milestone on Oct 29, 2015
  2. tacaswell commented on Oct 29, 2015

    @tacaswell
    Member

    That looks right! Can you put in a pull request with that change?

  3. added
    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Oct 29, 2015
  4. jcolonese commented on Oct 29, 2015

    @jcolonese
    Author

    I'm new in gitHub but I'll try it.

  5. added a commit that references this issue on Oct 29, 2015
  6. tacaswell commented on Oct 29, 2015

    @tacaswell
    Member

    We were all new to gh once 😉

  7. modified the milestones: , on Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions