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

Appearance settings

Commit 75ef70b

Browse filesBrowse files
committed
Minor cleanup of hist().
1 parent e086a5d commit 75ef70b
Copy full SHA for 75ef70b

File tree

Expand file treeCollapse file tree

1 file changed

+9
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-14
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+9-14Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6273,28 +6273,23 @@ def _normalize_input(inp, ename='input'):
62736273
totwidth = np.diff(bins)
62746274

62756275
if rwidth is not None:
6276-
dr = min(1.0, max(0.0, rwidth))
6276+
dr = np.clip(rwidth, 0, 1)
62776277
elif (len(n) > 1 and
62786278
((not stacked) or rcParams['_internal.classic_mode'])):
62796279
dr = 0.8
62806280
else:
62816281
dr = 1.0
62826282

62836283
if histtype == 'bar' and not stacked:
6284-
width = dr*totwidth/nx
6284+
width = dr * totwidth / nx
62856285
dw = width
6286-
6287-
if nx > 1:
6288-
boffset = -0.5*dr*totwidth*(1.0-1.0/nx)
6289-
else:
6290-
boffset = 0.0
6291-
stacked = False
6286+
boffset = -0.5 * dr * totwidth * (1 - 1 / nx)
62926287
elif histtype == 'barstacked' or stacked:
6293-
width = dr*totwidth
6288+
width = dr * totwidth
62946289
boffset, dw = 0.0, 0.0
62956290

62966291
if align == 'mid' or align == 'edge':
6297-
boffset += 0.5*totwidth
6292+
boffset += 0.5 * totwidth
62986293
elif align == 'right':
62996294
boffset += totwidth
63006295

@@ -6307,7 +6302,7 @@ def _normalize_input(inp, ename='input'):
63076302

63086303
for m, c in zip(n, color):
63096304
if bottom is None:
6310-
bottom = np.zeros(len(m), float)
6305+
bottom = np.zeros(len(m))
63116306
if stacked:
63126307
height = m - bottom
63136308
else:
@@ -6326,14 +6321,14 @@ def _normalize_input(inp, ename='input'):
63266321

63276322
elif histtype.startswith('step'):
63286323
# these define the perimeter of the polygon
6329-
x = np.zeros(4 * len(bins) - 3, float)
6330-
y = np.zeros(4 * len(bins) - 3, float)
6324+
x = np.zeros(4 * len(bins) - 3)
6325+
y = np.zeros(4 * len(bins) - 3)
63316326

63326327
x[0:2*len(bins)-1:2], x[1:2*len(bins)-1:2] = bins, bins[:-1]
63336328
x[2*len(bins)-1:] = x[1:2*len(bins)-1][::-1]
63346329

63356330
if bottom is None:
6336-
bottom = np.zeros(len(bins)-1, float)
6331+
bottom = np.zeros(len(bins) - 1)
63376332

63386333
y[1:2*len(bins)-1:2], y[2:2*len(bins):2] = bottom, bottom
63396334
y[2*len(bins)-1:] = y[1:2*len(bins)-1][::-1]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.