Title: No space before unit symbol when there is no SI prefix in ticker.EngFormatter · Issue #6009 · matplotlib/matplotlib · GitHub
Open Graph Title: No space before unit symbol when there is no SI prefix in ticker.EngFormatter · Issue #6009 · matplotlib/matplotlib
X Title: No space before unit symbol when there is no SI prefix in ticker.EngFormatter · Issue #6009 · matplotlib/matplotlib
Description: I just discovered the EngFormatter in matplotlib.ticker, something I was looking for since a long time :). Playing a bit with it, it seems to me that a space is missing before the unit symbol when no SI prefix is needed. For example 1e3 ...
Open Graph Description: I just discovered the EngFormatter in matplotlib.ticker, something I was looking for since a long time :). Playing a bit with it, it seems to me that a space is missing before the unit symbol when ...
X Description: I just discovered the EngFormatter in matplotlib.ticker, something I was looking for since a long time :). Playing a bit with it, it seems to me that a space is missing before the unit symbol when ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/6009
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"No space before unit symbol when there is no SI prefix in ticker.EngFormatter","articleBody":"I just discovered the EngFormatter in matplotlib.ticker, something I was looking for since a long time :). Playing a bit with it, it seems to me that a space is missing before the unit symbol when no SI prefix is needed. For example 1e3 seconds is rendered correctly by “1 ks” but 10 seconds is displayed “10s” (which is wrong afaik about English typography).\n\nI looked rapidly into the EngFormatter class, and I think the problem can be solved by tweaking the format_eng method, for example like in the following patch: \n\n'''\nNB: At the end, the ticklabel will basically be the string s = \"%s%s\" % (self.format_eng(x), self.unit)\nSo the idea is just to enforce an additional space at the end of what format_eng returns when there is no SI prefix but a unit is specified.\n'''\n# Vanilla return\n\nreturn formatted.strip()\n# Patched return\n\nstripped_formatted = formatted.strip()\nif (self.unit is not \"\") and (prefix is self.ENG_PREFIXES[0]):\n stripped_formatted = stripped_formatted + \" \"\nreturn stripped_formatted\n\nMaybe there is a better way to achieve this though. (BTW, I'm sorry but I didn't achieve to get indentation working for the “if” statement). To demonstrate the problem and the proposed solution, I attach a ZIP with a script that plots the same axes with both the vanilla EngFormatter and my patched version, and the produced figure as a PDF: [Proposition_of_patch_for_EngFormatter.zip](https://github.com/matplotlib/matplotlib/files/132511/Proposition_of_patch_for_EngFormatter.zip)\n. \n","author":{"url":"https://github.com/afvincent","@type":"Person","name":"afvincent"},"datePublished":"2016-02-16T13:15:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/6009/matplotlib/issues/6009"}
| 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:332935af-db68-2926-9cf8-0ea895cf3bef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D51C:2E80A1:2E6899:42B7F5:6A55D993 |
| html-safe-nonce | 53192bd416c062ed15aed3b3e0485639c29bd77c9a8eac45ab281c5857378725 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTFDOjJFODBBMToyRTY4OTk6NDJCN0Y1OjZBNTVEOTkzIiwidmlzaXRvcl9pZCI6IjM2NDc3MjkxNDI2MzA4NzUwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c8890e055b1c99560b1c3ff84e8668c746de00100e93fa8b7d898a8bbeccfcd3 |
| hovercard-subject-tag | issue:133979278 |
| 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/6009/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4a8580778ab0a0455b97e55097d39d3d535ef1e0486c34f7e08d775e6683a167/matplotlib/matplotlib/issues/6009 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4a8580778ab0a0455b97e55097d39d3d535ef1e0486c34f7e08d775e6683a167/matplotlib/matplotlib/issues/6009 |
| og:image:alt | I just discovered the EngFormatter in matplotlib.ticker, something I was looking for since a long time :). Playing a bit with it, it seems to me that a space is missing before the unit symbol when ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | afvincent |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 8f8e1726192df8dce16872ceb503336c12e9ae78 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width