Title: Inconsistent indexing of row and column label cells by Tables · Issue #12931 · matplotlib/matplotlib · GitHub
Open Graph Title: Inconsistent indexing of row and column label cells by Tables · Issue #12931 · matplotlib/matplotlib
X Title: Inconsistent indexing of row and column label cells by Tables · Issue #12931 · matplotlib/matplotlib
Description: In presence of row and column labels, the cell indexing by the Table class is inconsistent: column labels have row index 0, but row labels have column index -1: from pylab import * gca().set_axis_off() t = table( cellText=[["a", "b"], ["...
Open Graph Description: In presence of row and column labels, the cell indexing by the Table class is inconsistent: column labels have row index 0, but row labels have column index -1: from pylab import * gca().set_axis_o...
X Description: In presence of row and column labels, the cell indexing by the Table class is inconsistent: column labels have row index 0, but row labels have column index -1: from pylab import * gca().set_axis_o...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12931
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistent indexing of row and column label cells by Tables","articleBody":"In presence of row and column labels, the cell indexing by the Table class is inconsistent: column labels have row index 0, but row labels have column index -1:\r\n```\r\nfrom pylab import *\r\ngca().set_axis_off()\r\nt = table(\r\n cellText=[[\"a\", \"b\"], [\"c\", \"d\"]],\r\n rowLabels=[\"row1\", \"row2\"],\r\n colLabels=[\"col1\", \"col2\"],\r\n)\r\nfor (i, j), cell in sorted(t.get_celld().items()):\r\n print(i, j, cell.get_text())\r\nshow()\r\n```\r\ngives\r\n```\r\n0 0 Text(0, 0, 'col1')\r\n0 1 Text(0, 0, 'col2')\r\n1 -1 Text(0, 0, 'row1')\r\n1 0 Text(0, 0, 'a')\r\n1 1 Text(0, 0, 'b')\r\n2 -1 Text(0, 0, 'row2')\r\n2 0 Text(0, 0, 'c')\r\n2 1 Text(0, 0, 'd')\r\n```\r\n\r\nAs an example of bug caused by this API, the `text_labels_and_annotations/font_table_ttf_sfskip.py` example contains the seemingly innocuous code\r\n```\r\n if row \u003e 0 and col \u003e 0:\r\n cell.set_text_props(fontproperties=FontProperties(fname=fontname))\r\n```\r\nbut running the example, passing a local font pathname as argument (e.g. `python examples/text_labels_and_annotations/font_table_ttf_sgskip.py lib/matplotlib/mpl-data/fonts/ttf/cmr10.ttf` from the mpl root directory) shows that the first column of characters is not using the correct font.\r\n\r\n\r\nIndeed, the correct code would have been\r\n```\r\n if row \u003e 0 and col \u003e -1:\r\n cell.set_text_props(fontproperties=FontProperties(fname=fontname))\r\n```\r\nwhich gives\r\n\r\n\r\nI think the inconsistency is error-prone enough to consider changing it (probably handling the deprecations depending on the value of a global switch).","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2018-12-05T00:05:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/12931/matplotlib/issues/12931"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9997e8b1-d1db-786e-1696-ada63d9ebe84 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA3E:498C8:1450E9A:1B4718D:6A56C8C0 |
| html-safe-nonce | 1d8fddbf914805608d8a2e9156ec39e167c68162c8ba723e238a6288f681fdad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTNFOjQ5OEM4OjE0NTBFOUE6MUI0NzE4RDo2QTU2QzhDMCIsInZpc2l0b3JfaWQiOiIxMjA4MzE0ODM3NzczNzY0ODAwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 164ff73b5548e82e1c9431f8f6bf91e32fc9d204fc7afd3d0c12c5433af9806c |
| hovercard-subject-tag | issue:387534740 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/12931/issue_layout |
| twitter:image | https://opengraph.githubassets.com/91d0df28eee55f035576e5df9be51ef06fb3bae03bb2b00b5ceec6faf13dcf84/matplotlib/matplotlib/issues/12931 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/91d0df28eee55f035576e5df9be51ef06fb3bae03bb2b00b5ceec6faf13dcf84/matplotlib/matplotlib/issues/12931 |
| og:image:alt | In presence of row and column labels, the cell indexing by the Table class is inconsistent: column labels have row index 0, but row labels have column index -1: from pylab import * gca().set_axis_o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| hostname | github.com |
| expected-hostname | github.com |
| None | df99b7164e1d961b639cf5d3cbd6b5ba673edc67bd7e47cdc4746b96099e11ae |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3146ab55fc8763ab0e1d2a875e600b3a545bc751 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width