Title: [Bug]: `secondary_xaxis` produces ticks at incorrect locations · Issue #29067 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: `secondary_xaxis` produces ticks at incorrect locations · Issue #29067 · matplotlib/matplotlib
X Title: [Bug]: `secondary_xaxis` produces ticks at incorrect locations · Issue #29067 · matplotlib/matplotlib
Description: Bug summary It is possible I'm doing this incorrectly, but for a very simple example secondary_xaxis puts tick marks at incorrect locations. Modifying slightly the interpolation example from here https://matplotlib.org/stable/gallery/sub...
Open Graph Description: Bug summary It is possible I'm doing this incorrectly, but for a very simple example secondary_xaxis puts tick marks at incorrect locations. Modifying slightly the interpolation example from here h...
X Description: Bug summary It is possible I'm doing this incorrectly, but for a very simple example secondary_xaxis puts tick marks at incorrect locations. Modifying slightly the interpolation example from he...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29067
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: `secondary_xaxis` produces ticks at incorrect locations","articleBody":"### Bug summary\n\nIt is possible I'm doing this incorrectly, but for a very simple example `secondary_xaxis` puts tick marks at incorrect locations. Modifying slightly the interpolation example from here https://matplotlib.org/stable/gallery/subplots_axes_and_figures/secondary_axis.html:\n\n### Code for reproduction\n\n```Python\nfig, ax = plt.subplots(constrained_layout=True)\r\nxdata = np.arange(0, 11, 0.4)\r\nydata = np.random.randn(len(xdata))\r\nax.plot(xdata, ydata, label='Plotted data')\r\nax.set_xlabel('X [m]')\r\nax.legend()\r\nxnew = xdata**2\r\n\r\n\r\ndef forward(x):\r\n return np.interp(x, xdata, xnew)\r\n\r\n\r\ndef inverse(x):\r\n return np.interp(x, xnew, xdata)\r\n\r\nsecax = ax.secondary_xaxis('top', functions=(forward, inverse))\r\nsecax.xaxis.set_minor_locator(AutoMinorLocator())\r\nsecax.set_xlabel('$X_{other}$')\r\n\r\nplt.show()\n```\n\n\n### Actual outcome\n\n\u003cimg width=\"627\" alt=\"image\" src=\"https://github.com/user-attachments/assets/cb45f32e-4f53-4f6a-ad9d-4eed2c948c35\"\u003e\r\n\n\n### Expected outcome\n\nNotice that e.g. 0 on the lower axis is not aligned with 0 on the top and 10 on the bottom is not aligned with 100 on the top.\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nOS/X\n\n### Matplotlib Version\n\n3.9.2\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\n3.10.14\n\n### Jupyter version\n\n7.2.2\n\n### Installation\n\npip","author":{"url":"https://github.com/dkweiss31","@type":"Person","name":"dkweiss31"},"datePublished":"2024-11-04T14:34:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/29067/matplotlib/issues/29067"}
| 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:284d671d-ff10-c890-dc76-a402f96aee92 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 842A:176010:B22541:EEBF41:6A531974 |
| html-safe-nonce | 4872985f2141ecd98fd9294e5c108e2e0acd674c811c7e3b897bfb489c7894d8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDJBOjE3NjAxMDpCMjI1NDE6RUVCRjQxOjZBNTMxOTc0IiwidmlzaXRvcl9pZCI6IjUwNTk1NTYzNzUwOTAzNzA5MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0fad0e11f79646e22c0faabf5c32d01f0fb5116f81620ec58c725e713fb6c8bc |
| hovercard-subject-tag | issue:2632986583 |
| 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/29067/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6da386e40153852de4d31df4894e37048b743d2e994bb76b9c5edfa581910bbd/matplotlib/matplotlib/issues/29067 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6da386e40153852de4d31df4894e37048b743d2e994bb76b9c5edfa581910bbd/matplotlib/matplotlib/issues/29067 |
| og:image:alt | Bug summary It is possible I'm doing this incorrectly, but for a very simple example secondary_xaxis puts tick marks at incorrect locations. Modifying slightly the interpolation example from here h... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dkweiss31 |
| 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