Title: Axes.hist with log=True, histtype='step...' ignores bottom kwarg · Issue #4606 · matplotlib/matplotlib · GitHub
Open Graph Title: Axes.hist with log=True, histtype='step...' ignores bottom kwarg · Issue #4606 · matplotlib/matplotlib
X Title: Axes.hist with log=True, histtype='step...' ignores bottom kwarg · Issue #4606 · matplotlib/matplotlib
Description: The Axes.hist method doesn't handle the bottom kwarg properly when given log=True and histtype='step' or histtype='stepfilled'. As the example below shows, the method sets a minimum value to prevent issues with zeros on a log scale, but ...
Open Graph Description: The Axes.hist method doesn't handle the bottom kwarg properly when given log=True and histtype='step' or histtype='stepfilled'. As the example below shows, the method sets a minimum value to preven...
X Description: The Axes.hist method doesn't handle the bottom kwarg properly when given log=True and histtype='step' or histtype='stepfilled'. As the example below shows, the method sets a min...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/4606
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Axes.hist with log=True, histtype='step...' ignores bottom kwarg","articleBody":"The `Axes.hist` method doesn't handle the `bottom` kwarg properly when given `log=True` and `histtype='step'` or `histtype='stepfilled'`. As the example below shows, the method sets a `minimum` value to prevent issues with zeros on a log scale, but that supercedes a non-zero `bottom` kwarg:\n\n``` python\nimport numpy\nfrom matplotlib import pyplot\nfig = pyplot.figure()\nax = fig.gca()\nax.hist(numpy.random.random(1000), bins=100, log=True, bottom=1e-2, histtype='stepfilled')\nax.set_ylim(1e-2, 1e3)\nax.set_title('Bottom should be 1e-2, but instead is 1/base')\n```\n\n\n\nI can correct the issue with the following edit:\n\n``` diff\ndiff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py\nindex 4d10e86..2392a6d 100644\n--- a/lib/matplotlib/axes/_axes.py\n+++ b/lib/matplotlib/axes/_axes.py\n@@ -5779,7 +5779,9 @@ class Axes(_AxesBase):\n logbase = self.yaxis._scale.base\n\n # Setting a minimum of 0 results in problems for log plots\n- if normed or weights is not None:\n+ if np.min(bottom) \u003e 0:\n+ minimum = np.min(bottom)\n+ elif normed or weights is not None:\n # For normed data, set to log base * minimum data value\n # (gives 1 full tick-label unit for the lowest filled bin)\n ndata = np.array(n)\n```\n\nwhich uses the `bottom` value to set the `minimum` if it's nonzero. If this is confirmed as a bug, I can open a PR.\n","author":{"url":"https://github.com/duncanmmacleod","@type":"Person","name":"duncanmmacleod"},"datePublished":"2015-07-08T19:39:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/4606/matplotlib/issues/4606"}
| 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:77bac14c-ba99-ddc3-700d-b3a984282d7e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A0E:15934D:102579:15C5C2:6A52BFEC |
| html-safe-nonce | e47529c4337226ae3388dd588c58b96e271d97327b3f89c8fb3131f556f5185a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTBFOjE1OTM0RDoxMDI1Nzk6MTVDNUMyOjZBNTJCRkVDIiwidmlzaXRvcl9pZCI6IjEzOTc4NTg0NzkwNTQ3MDA1MjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c0da4dc4f826ad94c9b116912cd3bb3165c8798f04e20bdd6e56eb7862367f53 |
| hovercard-subject-tag | issue:93872656 |
| 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/4606/issue_layout |
| twitter:image | https://opengraph.githubassets.com/07a3fff21184dd429a97dd2972ed2637add52078c60054060898415618b9d08b/matplotlib/matplotlib/issues/4606 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/07a3fff21184dd429a97dd2972ed2637add52078c60054060898415618b9d08b/matplotlib/matplotlib/issues/4606 |
| og:image:alt | The Axes.hist method doesn't handle the bottom kwarg properly when given log=True and histtype='step' or histtype='stepfilled'. As the example below shows, the method sets a minimum value to preven... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | duncanmmacleod |
| 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