{"action":"created","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/6085","repository_url":"https://api.github.com/repos/matplotlib/matplotlib","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/6085/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/6085/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/6085/events","html_url":"https://github.com/matplotlib/matplotlib/pull/6085","id":137522677,"node_id":"MDExOlB1bGxSZXF1ZXN0NjEyMTU2ODU=","number":6085,"title":"Optimize 3D display","user":{"login":"AlexandreAbraham","id":1647301,"node_id":"MDQ6VXNlcjE2NDczMDE=","avatar_url":"https://avatars0.githubusercontent.com/u/1647301?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexandreAbraham","html_url":"https://github.com/AlexandreAbraham","followers_url":"https://api.github.com/users/AlexandreAbraham/followers","following_url":"https://api.github.com/users/AlexandreAbraham/following{/other_user}","gists_url":"https://api.github.com/users/AlexandreAbraham/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexandreAbraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexandreAbraham/subscriptions","organizations_url":"https://api.github.com/users/AlexandreAbraham/orgs","repos_url":"https://api.github.com/users/AlexandreAbraham/repos","events_url":"https://api.github.com/users/AlexandreAbraham/events{/privacy}","received_events_url":"https://api.github.com/users/AlexandreAbraham/received_events","type":"User","site_admin":false},"labels":[{"id":815558876,"node_id":"MDU6TGFiZWw4MTU1NTg4NzY=","url":"https://api.github.com/repos/matplotlib/matplotlib/labels/Needs%20rebase","name":"Needs rebase","color":"e27e6a","default":false},{"id":116757,"node_id":"MDU6TGFiZWwxMTY3NTc=","url":"https://api.github.com/repos/matplotlib/matplotlib/labels/mplot3d","name":"mplot3d","color":"02e10c","default":false}],"state":"closed","locked":false,"assignee":{"login":"NelleV","id":184798,"node_id":"MDQ6VXNlcjE4NDc5OA==","avatar_url":"https://avatars0.githubusercontent.com/u/184798?v=4","gravatar_id":"","url":"https://api.github.com/users/NelleV","html_url":"https://github.com/NelleV","followers_url":"https://api.github.com/users/NelleV/followers","following_url":"https://api.github.com/users/NelleV/following{/other_user}","gists_url":"https://api.github.com/users/NelleV/gists{/gist_id}","starred_url":"https://api.github.com/users/NelleV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NelleV/subscriptions","organizations_url":"https://api.github.com/users/NelleV/orgs","repos_url":"https://api.github.com/users/NelleV/repos","events_url":"https://api.github.com/users/NelleV/events{/privacy}","received_events_url":"https://api.github.com/users/NelleV/received_events","type":"User","site_admin":false},"assignees":[{"login":"NelleV","id":184798,"node_id":"MDQ6VXNlcjE4NDc5OA==","avatar_url":"https://avatars0.githubusercontent.com/u/184798?v=4","gravatar_id":"","url":"https://api.github.com/users/NelleV","html_url":"https://github.com/NelleV","followers_url":"https://api.github.com/users/NelleV/followers","following_url":"https://api.github.com/users/NelleV/following{/other_user}","gists_url":"https://api.github.com/users/NelleV/gists{/gist_id}","starred_url":"https://api.github.com/users/NelleV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NelleV/subscriptions","organizations_url":"https://api.github.com/users/NelleV/orgs","repos_url":"https://api.github.com/users/NelleV/repos","events_url":"https://api.github.com/users/NelleV/events{/privacy}","received_events_url":"https://api.github.com/users/NelleV/received_events","type":"User","site_admin":false}],"milestone":null,"comments":26,"created_at":"2016-03-01T09:42:06Z","updated_at":"2018-07-15T21:56:46Z","closed_at":"2018-05-02T17:28:27Z","author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/6085","html_url":"https://github.com/matplotlib/matplotlib/pull/6085","diff_url":"https://github.com/matplotlib/matplotlib/pull/6085.diff","patch_url":"https://github.com/matplotlib/matplotlib/pull/6085.patch"},"body":"While printing 3D objects, I noticed that the display was pretty slow. The reason is that matplotlib relies a lot on list of objects instead of using big numpy arrays to fasten 3D projections.\n\nThis PR aims at solving part of this problem. I replaced some airthmetic on list of vectors by artihmetic on big matrices. This impacts mainly 3D display.\n\nI work on neuroimaging data. I noticed an approximate 25% speedup optimization on 3D display (depending on the complexity of the figure). Refreshment in interactive plotting is also faster. Example script:\n\n``` python\nfrom matplotlib import pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nfrom nibabel import gifti\n\n\nsurf_mesh = '/path/to/spm12b/canonical/cortex_20484.surf.gii'\n\ncoords, faces = gifti.read(surf_mesh).getArraysFromIntent(1008)[0].data, \\\n                gifti.read(surf_mesh).getArraysFromIntent(1009)[0].data\n\nlimits = [coords.min(), coords.max()]\n\ncmap = 'coolwarm'\n\nfig = plt.figure()\nax = fig.add_subplot(111, projection='3d', xlim=limits, ylim=limits)\nax.view_init(elev=0, azim=0)\nax.set_axis_off()\n\np3dcollec = ax.plot_trisurf(coords[:, 0], coords[:, 1], coords[:, 2],\n                            triangles=faces, linewidth=0.,\n                            antialiased=False,\n                            color='white')\n\nfig.savefig('brain.png')\nplt.close(fig)\n```\n\nPossible other optimizations:\n- For display, matplotlib relies on a list of Path objects. This could be made faster with numpy arrays.\n- Poly3DCollection and others: a lot of unnecessary asarray and paddings of ones to obtain quaternions are done. This could be simplified by keeping a quaternion numpy array in the object and using appropriate numpy views but requires a deeper refactoring.\n- not plotting unseen triangle: For the moment, all polygons are drawn. if there are a lot, isn't it worth to compute which one are hidden by others and remove them?\n\n@agramfort and @juhuntenburg, do you notice significant running time reduction with this PR?\n"},"comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments/405121417","html_url":"https://github.com/matplotlib/matplotlib/pull/6085#issuecomment-405121417","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/6085","id":405121417,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTEyMTQxNw==","user":{"login":"rth","id":630936,"node_id":"MDQ6VXNlcjYzMDkzNg==","avatar_url":"https://avatars0.githubusercontent.com/u/630936?v=4","gravatar_id":"","url":"https://api.github.com/users/rth","html_url":"https://github.com/rth","followers_url":"https://api.github.com/users/rth/followers","following_url":"https://api.github.com/users/rth/following{/other_user}","gists_url":"https://api.github.com/users/rth/gists{/gist_id}","starred_url":"https://api.github.com/users/rth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rth/subscriptions","organizations_url":"https://api.github.com/users/rth/orgs","repos_url":"https://api.github.com/users/rth/repos","events_url":"https://api.github.com/users/rth/events{/privacy}","received_events_url":"https://api.github.com/users/rth/received_events","type":"User","site_admin":false},"created_at":"2018-07-15T21:56:46Z","updated_at":"2018-07-15T21:56:46Z","author_association":"NONE","body":"This PR was continued in https://github.com/matplotlib/matplotlib/pull/11577"}}
{"actor":{"display_login":"rth"}}