Title: plt.hist density argument does not function as described. · Issue #10398 · matplotlib/matplotlib · GitHub
Open Graph Title: plt.hist density argument does not function as described. · Issue #10398 · matplotlib/matplotlib
X Title: plt.hist density argument does not function as described. · Issue #10398 · matplotlib/matplotlib
Description: Bug report Bug summary plt.hist density argument does not function as described. Code for reproduction import matplotlib.pyplot as plt import numpy as np x = np.asarray([0,0,0,0,1,1,2,2,2,2,3,3,3,3,3,3,3], dtype="float") n, bins, _ = plt...
Open Graph Description: Bug report Bug summary plt.hist density argument does not function as described. Code for reproduction import matplotlib.pyplot as plt import numpy as np x = np.asarray([0,0,0,0,1,1,2,2,2,2,3,3,3,3...
X Description: Bug report Bug summary plt.hist density argument does not function as described. Code for reproduction import matplotlib.pyplot as plt import numpy as np x = np.asarray([0,0,0,0,1,1,2,2,2,2,3,3,3,3...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/10398
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"plt.hist density argument does not function as described.","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\n\r\nplt.hist density argument does not function as described.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\nx = np.asarray([0,0,0,0,1,1,2,2,2,2,3,3,3,3,3,3,3], dtype=\"float\")\r\nn, bins, _ = plt.hist(x, density=1, bins=2)\r\nprint(n)\r\nprint(np.sum(n))\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\n```\r\n[0.23529412 0.43137255]\r\n0.6666666666666666\r\n```\r\n\r\n**Expected outcome**\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\nx = np.asarray([0,0,0,0,1,1,2,2,2,2,3,3,3,3,3,3,3], dtype=\"float\")\r\nn, bins, _ = plt.hist(x, density=1, bins=2)\r\nn /= np.sum(n) # As advertised\r\nprint(n)\r\nprint(np.sum(n))\r\n```\r\n\r\n```\r\n[0.35294118 0.64705882]\r\n1.0\r\n```\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: OSX High Sierra\r\n * Matplotlib version: 2.1.1\r\n * Matplotlib backend: MacOSX\r\n * Python version: 3.6.4\r\n * Other libraries: numpy 1.14.0\r\n * Installed via: pip3\r\n","author":{"url":"https://github.com/ryanpeach","@type":"Person","name":"ryanpeach"},"datePublished":"2018-02-08T15:44:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":45},"url":"https://github.com/10398/matplotlib/issues/10398"}
| 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:78fd10a5-be17-510f-b045-698ba81fb331 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E0CE:24214A:A069C7:DC4435:6A5399CB |
| html-safe-nonce | 55feeb60b727e4e02d19445ec53acc1c93a6853f6d9152f1ea661d63c39087c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMENFOjI0MjE0QTpBMDY5Qzc6REM0NDM1OjZBNTM5OUNCIiwidmlzaXRvcl9pZCI6Ijc5MTgzNjcxMjM5MzQ4MDY1MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6a0377ff864baa8dc525da72458ad2c1d8444d3ccd7f4353589bc052dd5a2f0e |
| hovercard-subject-tag | issue:295560733 |
| 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/10398/issue_layout |
| twitter:image | https://opengraph.githubassets.com/304fab23620288d5dfb627c11c5965610fd524bef9ac208339d308ae5f61c59b/matplotlib/matplotlib/issues/10398 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/304fab23620288d5dfb627c11c5965610fd524bef9ac208339d308ae5f61c59b/matplotlib/matplotlib/issues/10398 |
| og:image:alt | Bug report Bug summary plt.hist density argument does not function as described. Code for reproduction import matplotlib.pyplot as plt import numpy as np x = np.asarray([0,0,0,0,1,1,2,2,2,2,3,3,3,3... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ryanpeach |
| 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