Title: Wedged polar plot's position/scaling leaves too much white space. · Issue #10264 · matplotlib/matplotlib · GitHub
Open Graph Title: Wedged polar plot's position/scaling leaves too much white space. · Issue #10264 · matplotlib/matplotlib
X Title: Wedged polar plot's position/scaling leaves too much white space. · Issue #10264 · matplotlib/matplotlib
Description: Coming from this stackoverflow question, some strange (to me) behaviour is observed when plotting partial or wedged polar plots. This new feature, which can be used by setting .set_thetamin and .set_thetamax on a polar plot, allows to pl...
Open Graph Description: Coming from this stackoverflow question, some strange (to me) behaviour is observed when plotting partial or wedged polar plots. This new feature, which can be used by setting .set_thetamin and .se...
X Description: Coming from this stackoverflow question, some strange (to me) behaviour is observed when plotting partial or wedged polar plots. This new feature, which can be used by setting .set_thetamin and .se...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/10264
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wedged polar plot's position/scaling leaves too much white space.","articleBody":"Coming from [this stackoverflow question](https://stackoverflow.com/questions/48289129/removing-space-around-wedge-polar-plots-in-matplotlib), some strange (to me) behaviour is observed when plotting partial or wedged polar plots. This new feature, which can be used by setting `.set_thetamin` and `.set_thetamax` on a polar plot, allows to plot only part of a polar plot without the need to use [floating axes](https://matplotlib.org/2.0.2/mpl_toolkits/axes_grid/users/overview.html#floating-axes) - which is of course a great feature. \r\n\r\nThe problem arises when either using those partial polar plots as subplots or when trying to plot them tightly in a figure. It seems like their position is always set to be in the middle of some kind of subplot with aspect ratio of 1. Especially when using a half circle polar plot, this causes a lot of unnecessary white space around the half-circle. \r\n\r\nConsider this code:\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\nfig, axes = plt.subplots(1, 2, subplot_kw={'projection': 'polar'},\r\n figsize=(8, 4))\r\n\r\nfor i, theta_max in enumerate([2*np.pi, np.pi]):\r\n\r\n # define theta vector with varying end point and some data to plot\r\n theta = np.linspace(0, theta_max, 181)\r\n axes[i].set_thetamin(0)\r\n axes[i].set_thetamax(theta_max*180/np.pi)\r\n\r\n axes[i].set_xlabel('Magnitude', fontsize=15)\r\n axes[i].set_ylabel('Angles', fontsize=15)\r\n\r\nplt.savefig(\"polarwedges2.svg\", facecolor=\"#e8f4f2\")\r\n```\r\n\r\nwhich produces the top plot in the below image. I have manually marked the region which is occupied by the polar plot, calling it \"Incompressible BBox\", because it occupies much more space than desired, also making the xlabel appearing totally off. The picture below is what I would expect this subplot to behave like.\r\n\r\n\r\n\r\nThe \"imcompressibility\" of that box also prevents to have such a half-circle polar plot tight in a figure. \r\nIn the following code a simple figure with such a plot is attempted.\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n\r\nfig, ax = plt.subplots(1, 1, figsize=(6,3.4), subplot_kw={'projection': 'polar'})\r\n\r\n# set 'thetamin' and 'thetamax' according to data\r\nax.set_thetamin(0)\r\nax.set_thetamax(180)\r\n\r\nax.set_xlabel('Magnitude', fontsize=15)\r\nax.set_ylabel('Angles', fontsize=15)\r\n\r\nplt.savefig(\"polarwedge3.svg\", facecolor=\"#e8f4f2\")\r\n```\r\nThe plot appears much smaller than the figure would allow for and leaves a lot of white space around.\r\n\r\n\r\n\r\nThe only workaround I can currently think of is to make the original axes much larger than the figure (`ax.set_position( [0.1, -0.45, 0.8, 2])`) and shift the xlabel manually by some amount towards the top, as shown in the lower picture. Workaround code.\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n\r\nfig, ax = plt.subplots(1, 1, figsize=(6,3.4), subplot_kw={'projection': 'polar'})\r\n\r\n# set 'thetamin' and 'thetamax' according to data\r\nax.set_thetamin(0)\r\nax.set_thetamax(180)\r\n\r\nax.set_xlabel('Magnitude', fontsize=15, labelpad=-60)\r\nax.set_ylabel('Angles', fontsize=15)\r\n\r\nax.set_position( [0.1, -0.45, 0.8, 2])\r\nplt.savefig(\"polarwedge4.svg\", facecolor=\"#e8f4f2\")\r\n```\r\n\r\n\r\nI guess this behaviour is in general undesired. One would rather have either the same behaviour as for fixed aspect plots (like imshow, i.e. what is called \"compressible\" above) or even better, some API to set the position to useful values according to the usual subplot mechanism.\r\n","author":{"url":"https://github.com/ImportanceOfBeingErnest","@type":"Person","name":"ImportanceOfBeingErnest"},"datePublished":"2018-01-18T00:22:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/10264/matplotlib/issues/10264"}
| 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:78053480-7455-ac1c-7e82-bc5cb8cc66c4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB40:2E411E:103EC1E:15E134E:6A533528 |
| html-safe-nonce | c448db1017012d9f9ad767c0832024e367ad7f5a05756edd6f0b231d46bb9baf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjQwOjJFNDExRToxMDNFQzFFOjE1RTEzNEU6NkE1MzM1MjgiLCJ2aXNpdG9yX2lkIjoiMTEwNTYwMjMxODM4NzMyODI5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | afe395b304a7e562126529d220c9ad70e95b2177f1565b47b0be4cf639a89fa6 |
| hovercard-subject-tag | issue:289461442 |
| 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/10264/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7c0eb0bc5c408c395afbde46dd1c08503fb01f11cb9058d67f1865eac451aca9/matplotlib/matplotlib/issues/10264 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7c0eb0bc5c408c395afbde46dd1c08503fb01f11cb9058d67f1865eac451aca9/matplotlib/matplotlib/issues/10264 |
| og:image:alt | Coming from this stackoverflow question, some strange (to me) behaviour is observed when plotting partial or wedged polar plots. This new feature, which can be used by setting .set_thetamin and .se... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ImportanceOfBeingErnest |
| 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