Title: "Classical" zero-axis plot with arrows and symmetric ticks seems to be impossible · Issue #17157 · matplotlib/matplotlib · GitHub
Open Graph Title: "Classical" zero-axis plot with arrows and symmetric ticks seems to be impossible · Issue #17157 · matplotlib/matplotlib
X Title: "Classical" zero-axis plot with arrows and symmetric ticks seems to be impossible · Issue #17157 · matplotlib/matplotlib
Description: Bug report Bug summary I am trying to use matplotlib to produce classical "Mathematics-style" plots in production quality, with a cross of coordinate axes through the origin, arrow tips on the axes, and symmetic ("inout") ticks (in fact,...
Open Graph Description: Bug report Bug summary I am trying to use matplotlib to produce classical "Mathematics-style" plots in production quality, with a cross of coordinate axes through the origin, arrow tips on the axes...
X Description: Bug report Bug summary I am trying to use matplotlib to produce classical "Mathematics-style" plots in production quality, with a cross of coordinate axes through the origin, arrow tips o...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/17157
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Classical\" zero-axis plot with arrows and symmetric ticks seems to be impossible","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**Bug summary**\r\n\r\n\u003c!--A short 1-2 sentences that succinctly describes the bug--\u003e\r\n\r\nI am trying to use matplotlib to produce classical \"Mathematics-style\" plots in production quality, with a cross of coordinate axes through the origin, arrow tips on the axes, and symmetic (\"inout\") ticks (in fact, since the entire plot is symmetric, there is no in or out, so asymmetric tick placement looks out of place). \r\n\r\nFollowing axisartist-demo-axisline-style from the Matplotlib gallery, I am able to get the arrows, but it fails on the symmetric ticks. Using an alternative incantation which a student of mine came up with (I don't know where from), the symmetric ticks work, but we don't seem to be able to get arrow heads on the axes. \r\n\r\nBoth examples also differ in other placement decisions (why???), none is optimal, but all other things look fixable with some effort.\r\n\r\nI am not sure whether this is a documentation bug or a code bug, but what bugs me is the apparent impossibility to meet the two requirements, arrow heads and symmetric ticks, at once.\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\n#! /usr/bin/env python3\r\n\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom mpl_toolkits.axes_grid.axislines import SubplotZero\r\n\r\nplt.rcParams.update({'xtick.direction': \"inout\",\r\n 'ytick.direction': \"inout\"})\r\n\r\nxx = np.linspace(-np.pi, np.pi, 200)\r\n\r\n# from https://matplotlib.org/gallery/axisartist/demo_axisline_style.html#sphx-glr-gallery-axisartist-demo-axisline-style-py\r\nfig = plt.figure()\r\nax = SubplotZero(fig, 111)\r\nfig.add_subplot(ax)\r\n\r\nfor direction in [\"xzero\", \"yzero\"]:\r\n # adds arrows at the ends of each axis\r\n ax.axis[direction].set_axisline_style(\"-|\u003e\")\r\n \r\n # adds X and Y-axis from the origin\r\n ax.axis[direction].set_visible(True)\r\n\r\nfor direction in [\"left\", \"right\", \"bottom\", \"top\"]:\r\n # hides borders\r\n ax.axis[direction].set_visible(False)\r\n\r\nax.plot(xx, np.sin(xx))\r\nplt.title(\"Arrow heads work, symmetric ticks don't\")\r\nplt.show()\r\n\r\nfig = plt.figure()\r\nax = fig.add_subplot(1, 1, 1)\r\n\r\nax.spines['left'].set_position('zero')\r\nax.spines['bottom'].set_position('zero')\r\nax.spines['right'].set_color('none')\r\nax.spines['top'].set_color('none')\r\n\r\nax.plot(xx, np.sin(xx))\r\nplt.title(\"Symmetric ticks work, but how to get arrow heads?\")\r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\r\n\r\n\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**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 first plot should just produce symmetric ticks, as requested in the rcParams. For the second one, it might be missing documentation, I just don't know how to proceed. The differences between the two versions are very strange, and not documented in any obvious place.\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: Fedora 30\r\n * Matplotlib version: python3-matplotlib-3.0.3-2.fc30.x86_64\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): Qt5Agg\r\n * Python version: 3.7.6\r\n * Jupyter version (if applicable): N/A\r\n * Other libraries: N/A\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\nDefault Fedora 30 install.\r\n","author":{"url":"https://github.com/m-oliver","@type":"Person","name":"m-oliver"},"datePublished":"2020-04-16T14:25:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/17157/matplotlib/issues/17157"}
| 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:aa5bd4ca-3786-d295-d93e-955ffe109275 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6E4:0B26:8196E6:B16821:6A570374 |
| html-safe-nonce | 3e4686e5ca6f3a797e8ab1dbb18e1903984bd68d8a8ef830fbcb110deadd73d5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkU0OjBCMjY6ODE5NkU2OkIxNjgyMTo2QTU3MDM3NCIsInZpc2l0b3JfaWQiOiIyMjQwNzEyODM0MTM2MDgxMjY4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6bcfa801eb22540e073ff3f3c3261324a79ab5e8cd794f6c8087d453a57ebcfd |
| hovercard-subject-tag | issue:601102524 |
| 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/17157/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a9303dbcb0162b6d2983dba1220631b2865bae514f18336f50fb6a72baee4ec0/matplotlib/matplotlib/issues/17157 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a9303dbcb0162b6d2983dba1220631b2865bae514f18336f50fb6a72baee4ec0/matplotlib/matplotlib/issues/17157 |
| og:image:alt | Bug report Bug summary I am trying to use matplotlib to produce classical "Mathematics-style" plots in production quality, with a cross of coordinate axes through the origin, arrow tips on the axes... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | m-oliver |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb29e5f807bd95e41196adfbc6d28f9af12d89830d8b684f3e871774ddff2fc |
| 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 | b056788a129fb0194b61f2ebb4c43f6a9f4dfd27 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width