Title: Ylim with Bar Chart · Issue #19428 · matplotlib/matplotlib · GitHub
Open Graph Title: Ylim with Bar Chart · Issue #19428 · matplotlib/matplotlib
X Title: Ylim with Bar Chart · Issue #19428 · matplotlib/matplotlib
Description: I think the bar chart's ylim does not behave as expected. Based on the demo presented here , I have added plt.ylim(top=30) and bars extended outside. Expected behaviour is that bars will be cut-off at the top of the figure. import numpy ...
Open Graph Description: I think the bar chart's ylim does not behave as expected. Based on the demo presented here , I have added plt.ylim(top=30) and bars extended outside. Expected behaviour is that bars will be cut-off...
X Description: I think the bar chart's ylim does not behave as expected. Based on the demo presented here , I have added plt.ylim(top=30) and bars extended outside. Expected behaviour is that bars will be cut...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19428
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Ylim with Bar Chart","articleBody":"I think the bar chart's ylim does not behave as expected. \r\nBased on the demo presented [here ](https://matplotlib.org/2.0.2/examples/api/barchart_demo.html), I have added plt.ylim(top=30) and bars extended outside. \r\n\r\nExpected behaviour is that bars will be cut-off at the top of the figure.\r\n\r\n\r\n\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\nN = 5\r\nmen_means = (20, 35, 30, 35, 27)\r\nmen_std = (2, 3, 4, 1, 2)\r\n\r\nind = np.arange(N) # the x locations for the groups\r\nwidth = 0.35 # the width of the bars\r\n\r\nfig, ax = plt.subplots()\r\nrects1 = ax.bar(ind, men_means, width, color='r', yerr=men_std)\r\n\r\nwomen_means = (25, 32, 34, 20, 25)\r\nwomen_std = (3, 5, 2, 3, 3)\r\nrects2 = ax.bar(ind + width, women_means, width, color='y', yerr=women_std)\r\n\r\nax.set_ylabel('Scores')\r\nax.set_title('Scores by group and gender')\r\nax.set_xticks(ind + width / 2)\r\nax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))\r\n\r\nplt.ylim(top=30) # THIS IS THE PART I HAVE ADDED\r\n\r\nax.legend((rects1[0], rects2[0]), ('Men', 'Women'))\r\n\r\n\r\ndef autolabel(rects):\r\n for rect in rects:\r\n height = rect.get_height()\r\n ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,\r\n '%d' % int(height),\r\n ha='center', va='bottom')\r\n\r\nautolabel(rects1)\r\nautolabel(rects2)\r\n\r\nplt.show()\r\n```","author":{"url":"https://github.com/berkdemir","@type":"Person","name":"berkdemir"},"datePublished":"2021-02-02T10:29:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/19428/matplotlib/issues/19428"}
| 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:bdca7a27-41f9-8964-fab9-1b43b6e1321c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B3A0:1661F0:1C8AE60:25E2388:6A52D866 |
| html-safe-nonce | 379b2e14c7fa62a35fe54f460a62c7cfddccf99d66b30583845654e3707bdaaf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0EwOjE2NjFGMDoxQzhBRTYwOjI1RTIzODg6NkE1MkQ4NjYiLCJ2aXNpdG9yX2lkIjoiNjg5NDk4OTYxNjU4MTEwNTc2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7419290cc5deed0269c9eebfb087c0cf32d0fdae23bf8f55140463a1e6c020bd |
| hovercard-subject-tag | issue:799150053 |
| 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/19428/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8a2b7fadfcabfddc0c0fd246d80b9d9e6e6eebf08b3ee03e79eb50771ac394e0/matplotlib/matplotlib/issues/19428 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8a2b7fadfcabfddc0c0fd246d80b9d9e6e6eebf08b3ee03e79eb50771ac394e0/matplotlib/matplotlib/issues/19428 |
| og:image:alt | I think the bar chart's ylim does not behave as expected. Based on the demo presented here , I have added plt.ylim(top=30) and bars extended outside. Expected behaviour is that bars will be cut-off... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | berkdemir |
| 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