Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Axes.hist with log=True, histtype='step...' ignores bottom kwarg #4606

Closed
@duncanmmacleod

Description

@duncanmmacleod

TheAxes.hist method doesn't handle thebottom kwarg properly when givenlog=True andhisttype='step' orhisttype='stepfilled'. As the example below shows, the method sets aminimum value to prevent issues with zeros on a log scale, but that supercedes a non-zerobottom kwarg:

importnumpyfrommatplotlibimportpyplotfig=pyplot.figure()ax=fig.gca()ax.hist(numpy.random.random(1000),bins=100,log=True,bottom=1e-2,histtype='stepfilled')ax.set_ylim(1e-2,1e3)ax.set_title('Bottom should be 1e-2, but instead is 1/base')

mpl-hist-bottom

I can correct the issue with the following edit:

diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.pyindex 4d10e86..2392a6d 100644--- a/lib/matplotlib/axes/_axes.py+++ b/lib/matplotlib/axes/_axes.py@@ -5779,7 +5779,9 @@ class Axes(_AxesBase):                     logbase = self.yaxis._scale.base                 # Setting a minimum of 0 results in problems for log plots-                if normed or weights is not None:+                if np.min(bottom) > 0:+                    minimum = np.min(bottom)+                elif normed or weights is not None:                     # For normed data, set to log base * minimum data value                     # (gives 1 full tick-label unit for the lowest filled bin)                     ndata = np.array(n)

which uses thebottom value to set theminimum if it's nonzero. If this is confirmed as a bug, I can open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp