Title: [Annotations] ValueError: lines do not intersect when computing tight bounding box containing arrow with filled paths · Issue #12820 · matplotlib/matplotlib · GitHub
Open Graph Title: [Annotations] ValueError: lines do not intersect when computing tight bounding box containing arrow with filled paths · Issue #12820 · matplotlib/matplotlib
X Title: [Annotations] ValueError: lines do not intersect when computing tight bounding box containing arrow with filled paths · Issue #12820 · matplotlib/matplotlib
Description: Bug report During computation of tight_layout of subplots containing a histogram one gets a ValueError in bezier.py:35: Given lines do not intersect. Please verify that the angles are not equal or differ by 180 degrees. Could be related ...
Open Graph Description: Bug report During computation of tight_layout of subplots containing a histogram one gets a ValueError in bezier.py:35: Given lines do not intersect. Please verify that the angles are not equal or ...
X Description: Bug report During computation of tight_layout of subplots containing a histogram one gets a ValueError in bezier.py:35: Given lines do not intersect. Please verify that the angles are not equal or ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12820
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Annotations] ValueError: lines do not intersect when computing tight bounding box containing arrow with filled paths","articleBody":"\r\n\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\nDuring computation of tight_layout of subplots containing a histogram one gets a ValueError in bezier.py:35: Given lines do not intersect. Please verify that the angles are not equal or differ by 180 degrees.\r\n\r\nCould be related to #6076\r\n\r\n\u003c!--A short 1-2 sentences that succinctly describes the bug--\u003e\r\n\r\nSee the attached script and csv files to reproduce the bug. I have marked three FIXME code lines, that are all conditions for the bug to be triggered.\r\n\r\n1. use subplots with more than one axes.\r\n2. use annotations with an arrowprops argument.\r\n\r\nThis seems to be a regression in matplotlib 3, since the LTS version is running fine.\r\n\r\ntest files: [files.zip](https://github.com/matplotlib/matplotlib/files/2589658/files.zip)\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\n\r\ndef plot_1D_histogram_trajectories(data, centers=None,dtrajs=None, max_traj_length=200, ax=None):\r\n for n, _traj in enumerate(data):\r\n ax.hist(_traj, bins=30, alpha=.33, density=True, color='C{}'.format(n))\r\n ylims = ax.get_ylim()\r\n xlims = ax.get_xlim()\r\n\r\n for n, _traj in enumerate(data):\r\n ax.plot(\r\n _traj[:min(len(_traj), max_traj_length)],\r\n np.linspace(*ylims, min(len(_traj), max_traj_length)),\r\n alpha=0.6, color='C{}'.format(n), label='traj {}'.format(n))\r\n ax.plot(\r\n centers[dtrajs[n][:min(len(_traj), max_traj_length)]],\r\n np.linspace(*ylims, min(len(_traj), max_traj_length)),\r\n '.-', alpha=.6, label='dtraj {}'.format(n), linewidth=.3)\r\n ax.annotate(\r\n '', xy=(0.85 * xlims[1], 0.7 * ylims[1]), xytext=(0.85 * xlims[1], 0.3 * ylims[1]),\r\n # FIXME: if one omits this argument, it succeeds\r\n arrowprops=dict(),\r\n )\r\n ax.text(0.86 * xlims[1], 0.5 * ylims[1], '$x(time)$', ha='left', va='center', rotation=90)\r\n ax.legend(loc=2)\r\n\r\n# FIXME: if only one subfigure is created it succeeds\r\nfig, axes = plt.subplots(1, 2, figsize=(10, 4))\r\ndata = [np.loadtxt('data.csv')]\r\ndtraj = np.loadtxt('dtraj.csv').astype(int)\r\ncenters = np.loadtxt('centers.csv')\r\n\r\nplot_1D_histogram_trajectories(data, centers=centers, dtrajs=[dtraj], ax=axes[0])\r\naxes[1].plot(x=np.arange(10), y=np.arange(10))\r\nfig.tight_layout()\r\n```\r\nleads to\r\n```\r\n File \"/home/mi/marscher/sources/pyemma_tutorials/notebooks/minimal_example.py\", line 34, in \u003cmodule\u003e\r\n fig.tight_layout()\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/figure.py\", line 2374, in tight_layout\r\n pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/tight_layout.py\", line 366, in get_tight_layout_figure\r\n pad=pad, h_pad=h_pad, w_pad=w_pad)\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/tight_layout.py\", line 115, in auto_adjust_subplotpars\r\n tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/tight_layout.py\", line 116, in \u003clistcomp\u003e\r\n if ax.get_visible()])\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/axes/_base.py\", line 4396, in get_tightbbox\r\n bbox = a.get_tightbbox(renderer)\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/artist.py\", line 271, in get_tightbbox\r\n bbox = self.get_window_extent(renderer)\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/text.py\", line 2425, in get_window_extent\r\n bboxes.append(self.arrow_patch.get_window_extent())\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/patches.py\", line 548, in get_window_extent\r\n return self.get_path().get_extents(self.get_transform())\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/patches.py\", line 4228, in get_path\r\n _path, fillable = self.get_path_in_displaycoord()\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/patches.py\", line 4258, in get_path_in_displaycoord\r\n self.get_mutation_aspect())\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/patches.py\", line 3218, in __call__\r\n return self.transmute(path, mutation_size, linewidth)\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/patches.py\", line 3718, in transmute\r\n tail_width / 2.)\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/bezier.py\", line 381, in get_parallels\r\n cos_t2, sin_t2)\r\n File \"/srv/public/marscher/miniconda3/envs/nbtut/lib/python3.6/site-packages/matplotlib/bezier.py\", line 35, in get_intersection\r\n raise ValueError(\"Given lines do not intersect. Please verify that \"\r\nValueError: Given lines do not intersect. Please verify that the angles are not equal or differ by 180 degrees.\r\n```\r\n\r\n**Expected outcome**\r\n\r\nIt works, if the arrowprops are omitted, which means not to draw an arrow.\r\n\r\n**Matplotlib version**\r\n\r\n * Operating system: linux64\r\n * Matplotlib version: 3.0.2\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): module://backend_interagg\r\n * Python version: 3.6\r\n * Other libraries: see attached [conda_list.txt](https://github.com/matplotlib/matplotlib/files/2589659/conda_list.txt)\r\n\r\nInstalled with conda from conda-forge.\r\n\r\n","author":{"url":"https://github.com/marscher","@type":"Person","name":"marscher"},"datePublished":"2018-11-16T14:37:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/12820/matplotlib/issues/12820"}
| 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:491fa9e6-6562-65bf-c878-49a769fe2acd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9FCE:32BAC1:498535:62EE54:6A5296D5 |
| html-safe-nonce | fa9c10176be325e92a03a3ecbdad5439660645abd92a78680759992fffe2c341 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkNFOjMyQkFDMTo0OTg1MzU6NjJFRTU0OjZBNTI5NkQ1IiwidmlzaXRvcl9pZCI6IjkxMjU5MjE5NDUxMTE2NjQzNDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 45f3c3badde5a613032f43569aef6483931aeb6a384bda3bacd397d05188d7ee |
| hovercard-subject-tag | issue:381624938 |
| 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/12820/issue_layout |
| twitter:image | https://opengraph.githubassets.com/076842c3fc1c9b4e2fe637d6c00fe468d1c9b05574389a78587f9961236d9d18/matplotlib/matplotlib/issues/12820 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/076842c3fc1c9b4e2fe637d6c00fe468d1c9b05574389a78587f9961236d9d18/matplotlib/matplotlib/issues/12820 |
| og:image:alt | Bug report During computation of tight_layout of subplots containing a histogram one gets a ValueError in bezier.py:35: Given lines do not intersect. Please verify that the angles are not equal or ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | marscher |
| 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