Title: Width/height ratios not obeyed in complex plots with extra space · Issue #221 · proplot-dev/proplot · GitHub
Open Graph Title: Width/height ratios not obeyed in complex plots with extra space · Issue #221 · proplot-dev/proplot
X Title: Width/height ratios not obeyed in complex plots with extra space · Issue #221 · proplot-dev/proplot
Description: Description Setting share=0 in plot.subplots leads to (some) axes having non-equal width. Steps to reproduce Before using share=0 everything looks good, the axes in the middle row have the same width: import numpy as np import proplot as...
Open Graph Description: Description Setting share=0 in plot.subplots leads to (some) axes having non-equal width. Steps to reproduce Before using share=0 everything looks good, the axes in the middle row have the same wid...
X Description: Description Setting share=0 in plot.subplots leads to (some) axes having non-equal width. Steps to reproduce Before using share=0 everything looks good, the axes in the middle row have the same wid...
Opengraph URL: https://github.com/proplot-dev/proplot/issues/221
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Width/height ratios not obeyed in complex plots with extra space","articleBody":"### Description\r\n\r\nSetting `share=0` in `plot.subplots` leads to (some) axes having non-equal width.\r\n\r\n### Steps to reproduce\r\n\r\nBefore using `share=0` everything looks good, the axes in the middle row have the same width:\r\n```python\r\nimport numpy as np\r\nimport proplot as plot\r\n\r\n# simple function to extract axis widths\r\ndef get_widths(axs):\r\n return np.array([ax.get_position().bounds[2] for ax in axs])\r\n\r\n# plot geometry\r\narray = [[1, 1, 1, 2, 2, 2],\r\n [3, 3, 4, 4, 5, 5],\r\n [6, 6, 7, 7, 8, 8]]\r\n\r\n# axis in the second row is the reference\r\nfig, axs = plot.subplots(array, hratios=(2, 2, 2.5), ref=5)\r\n\r\n# check the widths\r\nwidths = get_widths(axs[2:5])\r\nprint(widths)\r\nprint('all widths equal:', (widths == widths[0]).all())\r\n```\r\nThis gives the following figure:\r\n\u003cimg src=https://user-images.githubusercontent.com/8452354/90953460-0c2b8100-e46c-11ea-9799-e8c48087135b.png width=\"350pix\"\u003e\r\n\r\nand prints:\r\n```\r\n[0.29239766 0.29239766 0.29239766]\r\nall widths equal: True\r\n```\r\n\r\nHowever, when I add `share=0` to the `plot.subplots` - the middle axis in the second row shrinks more than the outer axes:\r\n```python\r\nfig, axs = plot.subplots(array, hratios=(2, 2, 2.5), ref=5, share=0)\r\n```\r\n\u003cimg src=https://user-images.githubusercontent.com/8452354/90953508-51e84980-e46c-11ea-97d7-415ca35cdfdd.png width=\"350pix\"\u003e\r\n\r\nchecking the widths, I have to call `fig.canvas.draw()` to get the actual widths, because if the code below is run is the same code cell as the previous I first get widths that are not compatible width what I see in the figure:\r\n```python\r\nwidths = get_widths(axs[2:5])\r\nprint(widths)\r\nprint('all widths equal:', (widths == widths[0]).all())\r\n\r\nfig.canvas.draw()\r\nwidths = get_widths(axs[2:5])\r\nprint(widths)\r\nprint('all widths equal:', (widths == widths[0]).all())\r\n```\r\n\r\nwhich prints:\r\n```\r\n[0.26041667 0.26041667 0.26041667]\r\nall widths equal: False\r\n[0.2920774 0.2616831 0.2920774]\r\nall widths equal: False\r\n```\r\nonly the widths captured after figure redraw align with what I see in the figure.\r\nBut that is not so surprising, the actual issue are the non-equal widths of the axes in the second and third row.\r\n\r\n### Proplot version\r\n\r\n```\r\n0.6.4\r\n```\r\n\r\nPS. Thanks for the great package, makes creating complex multi-panel figures much easier!","author":{"url":"https://github.com/mmagnuski","@type":"Person","name":"mmagnuski"},"datePublished":"2020-08-22T09:55:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/221/proplot/issues/221"}
| 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:d99e28bb-0da2-25bb-9300-76f82ba66e2c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A83C:1BE2E:C48B:FDAB:697CD64C |
| html-safe-nonce | cb7737f8d42e27b2d7ee9e7b6c96a76dc384969e4845d0367a7574f92f0db160 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODNDOjFCRTJFOkM0OEI6RkRBQjo2OTdDRDY0QyIsInZpc2l0b3JfaWQiOiI0OTk1NTE2NjM0NTc2NTA4NDkyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7590179d722a798b652719507fb34e272ed83eb32ab9ad14eb0f8456f27c32a0 |
| hovercard-subject-tag | issue:683968967 |
| 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/proplot-dev/proplot/221/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6f17ef82d604d4440b262f7ecad49b602cede415fb598da0b38a1182075ace7e/proplot-dev/proplot/issues/221 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6f17ef82d604d4440b262f7ecad49b602cede415fb598da0b38a1182075ace7e/proplot-dev/proplot/issues/221 |
| og:image:alt | Description Setting share=0 in plot.subplots leads to (some) axes having non-equal width. Steps to reproduce Before using share=0 everything looks good, the axes in the middle row have the same wid... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mmagnuski |
| hostname | github.com |
| expected-hostname | github.com |
| None | 025b9e10ca829bdfe9cd8da6b55d0d4f68b8cf9a01e684b2843bf11849d7d948 |
| turbo-cache-control | no-preview |
| go-import | github.com/proplot-dev/proplot git https://github.com/proplot-dev/proplot.git |
| octolytics-dimension-user_id | 108025793 |
| octolytics-dimension-user_login | proplot-dev |
| octolytics-dimension-repository_id | 113293661 |
| octolytics-dimension-repository_nwo | proplot-dev/proplot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 113293661 |
| octolytics-dimension-repository_network_root_nwo | proplot-dev/proplot |
| 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 | 4a049c8dd66e29bfcb546b5f1ef4ceabb3f7501d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width