Title: Cleaning up the Formatter API · Issue #5787 · matplotlib/matplotlib · GitHub
Open Graph Title: Cleaning up the Formatter API · Issue #5787 · matplotlib/matplotlib
X Title: Cleaning up the Formatter API · Issue #5787 · matplotlib/matplotlib
Description: Still on my offset-text rewrite spree... Currently, the formatter API (in charge of picking the strings for the tick labels, axis offset and cursor position in the status bar) is a bit messy: the public methods available are Formatter.__...
Open Graph Description: Still on my offset-text rewrite spree... Currently, the formatter API (in charge of picking the strings for the tick labels, axis offset and cursor position in the status bar) is a bit messy: the p...
X Description: Still on my offset-text rewrite spree... Currently, the formatter API (in charge of picking the strings for the tick labels, axis offset and cursor position in the status bar) is a bit messy: the p...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/5787
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cleaning up the Formatter API","articleBody":"Still on my offset-text rewrite spree...\n\nCurrently, the formatter API (in charge of picking the strings for the tick labels, axis offset and cursor position in the status bar) is a bit messy: the public methods available are\n- `Formatter.__call__(self, val, idx)`: computes the label texts\n- `Formatter.format_data(self, val)`: not publicly used\n- `Formatter.format_data_short(self, val)`: computes the cursor position text\n- `Formatter.get_offset(self)`: returns the offset text\n- `Formatter.set_locs(self, locs)`: required for computing the labels\n- `Formatter.fix_minus(self, s)`: overriden only by ScalarFormatter to use a unicode minus\n\nFixedFormatter also provides `set_offset_string`.\n\nThe commonly used ScalarFormatter and LogFormatter also provide `pprint_val` (with different signatures, and not publicly used).\n\nScalarFormatter also provides a couple of getter/setters (for `useOffset`, `useLocale`, `scientific`, `powerlimits`); LogFormatter provides `base` and `label_minor` as _setters_ for instance variables.\n\nLogFormatterExponent and LogFormatterMathtext are variants of LogFormatter.\n\nEngFormatter also provides `format_eng` (not publicly used).\n\nThere are also a bunch of instance attributes which are public but probably intended as private.\n\nI propose simplifying the API to the following:\n- `Formatter.get_label_text(self, val: float, idx: int)`: computes the label texts\n- `Formatter.get_cursor_text(self, val: float)`: computes the cursor position text\n- `Formatter.get_offset_text(self)` and `Formatter.set_offset_text(self, s: str)`: get/set the offset text\n- `Formatter.set_locs(self, locs: array-like)`: because we need it\n- `Formatter.set_uselocale(self, b: bool)`: because there's no reason only ScalarFormatter has it\n\n(the new method names can be made to fallback on the old method names with a deprecation warning in the base class)\n\nand drop or make private basically everything else:\n- `fix_minus` (let's first check if any backend doesn't support unicode)\n- `pprint_val/format_eng`\n- the various instance attributes which should have been private to start with (keeping: `scientific`, `powerlimits`, `base`, `label_minor`, using getter/setters)\n\nand fold the `LogFormatterExponent` and `LogFormatterMathText` classes into options for the `LogFormatter` class.\n\nThoughts?\n","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2016-01-02T20:22:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/5787/matplotlib/issues/5787"}
| 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:2035c781-5172-e25b-2035-1611d3cedbd1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8846:24AA7C:5DD14C:805B4D:6A525367 |
| html-safe-nonce | 26d058046311b5525172fe2e0d81e1674a86d06d396ef465a502cc6c7bd34531 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODQ2OjI0QUE3Qzo1REQxNEM6ODA1QjREOjZBNTI1MzY3IiwidmlzaXRvcl9pZCI6IjU5OTExNzkxOTU4NDk1MjgxNjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8769f74eed90838fe967fc46482fa7d94f4e98bbff7bd42406b8b2a4483294a0 |
| hovercard-subject-tag | issue:124609899 |
| 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/5787/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d4620a907e6d509e452c1ff00e4331a7113c8f4c01d81cbcc34de6591d68dab8/matplotlib/matplotlib/issues/5787 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d4620a907e6d509e452c1ff00e4331a7113c8f4c01d81cbcc34de6591d68dab8/matplotlib/matplotlib/issues/5787 |
| og:image:alt | Still on my offset-text rewrite spree... Currently, the formatter API (in charge of picking the strings for the tick labels, axis offset and cursor position in the status bar) is a bit messy: the p... |
| 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 | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width