Title: secondary_xaxis doesn't seem to use formatters · Issue #15621 · matplotlib/matplotlib · GitHub
Open Graph Title: secondary_xaxis doesn't seem to use formatters · Issue #15621 · matplotlib/matplotlib
X Title: secondary_xaxis doesn't seem to use formatters · Issue #15621 · matplotlib/matplotlib
Description: Bug report secondary_xaxis (and secondary_yaxis?) doesn't seem to use formatters. Code for reproduction import matplotlib.pyplot as plt import numpy as np fig, axs = plt.subplots(figsize=(0.6*4,0.6*3)) y = np.random.rand(10) x = np.linsp...
Open Graph Description: Bug report secondary_xaxis (and secondary_yaxis?) doesn't seem to use formatters. Code for reproduction import matplotlib.pyplot as plt import numpy as np fig, axs = plt.subplots(figsize=(0.6*4,0.6...
X Description: Bug report secondary_xaxis (and secondary_yaxis?) doesn't seem to use formatters. Code for reproduction import matplotlib.pyplot as plt import numpy as np fig, axs = plt.subplots(figsize=(0.6*4...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/15621
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"secondary_xaxis doesn't seem to use formatters","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n`secondary_xaxis` (and `secondary_yaxis`?) doesn't seem to use formatters.\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug.\r\nPlease make sure to minimize the number of dependencies required, and provide\r\nany necessary plotted data.\r\nAvoid using threads, as Matplotlib is (explicitly) not thread-safe.--\u003e\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\nfig, axs = plt.subplots(figsize=(0.6*4,0.6*3))\r\ny = np.random.rand(10)\r\nx = np.linspace(30,200,num=10)\r\n\r\np = plt.plot(x, y, marker='o', markersize=3)\r\nplt.xscale(\"log\")\r\n\r\ndef m2rho(m):\r\n return 1 / m * 1000\r\n\r\ndef rho2m(rho):\r\n return 1 / rho * 1000\r\n\r\nsecax = axs.secondary_xaxis('top', functions=(m2rho, rho2m))\r\n\r\nfrom matplotlib.ticker import ScalarFormatter, NullFormatter\r\nfor axis in [axs.xaxis, secax.xaxis]:\r\n axis.set_major_formatter(ScalarFormatter())\r\n axis.set_minor_formatter(NullFormatter())\r\naxs.set_xticks([50, 100, 200])\r\nsecax.set_xticks([20,10,5])\r\n\r\nplt.tight_layout()\r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\n\r\n\r\n**Expected outcome**\r\n\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\r\n\r\nThe top axis should be formatted similarly to the bottom (first) x-axis. \r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: Ubuntu 18.04\r\n * Matplotlib version: 3.1.1\r\n * Matplotlib backend: Qt5Agg\r\n * Python version: 3.7.4\r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/fmikulasch","@type":"Person","name":"fmikulasch"},"datePublished":"2019-11-07T10:59:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/15621/matplotlib/issues/15621"}
| 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:e68a8236-a37f-73b9-b783-09d774584c3c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B14A:117213:1253C8:18718F:6A52ECF6 |
| html-safe-nonce | e57c5fc83858308dcb233d6526eec17582f8032afaab9f207b0f9e3616f56da4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTRBOjExNzIxMzoxMjUzQzg6MTg3MThGOjZBNTJFQ0Y2IiwidmlzaXRvcl9pZCI6IjgyNDIwNzMyMjU1NzYzOTkyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0902c02be6c286e15855473148c248b83d1f45a7885beb2571a9e097a3de50a8 |
| hovercard-subject-tag | issue:519193704 |
| 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/15621/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ced47fd789ddb723f0cd9ad18deee8f63c671e893c1f1f68c0e8525e468f2f8b/matplotlib/matplotlib/issues/15621 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ced47fd789ddb723f0cd9ad18deee8f63c671e893c1f1f68c0e8525e468f2f8b/matplotlib/matplotlib/issues/15621 |
| og:image:alt | Bug report secondary_xaxis (and secondary_yaxis?) doesn't seem to use formatters. Code for reproduction import matplotlib.pyplot as plt import numpy as np fig, axs = plt.subplots(figsize=(0.6*4,0.6... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fmikulasch |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width