Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3393a4f

Browse files
authored
Merge pull request #24832 from oscargus/bar_variable_naming
[MNT] Improve variable naming in bar
2 parents d27ecc1 + 52b3847 commit 3393a4f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6747,13 +6747,13 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
67476747
input_empty = False
67486748

67496749
if color is None:
6750-
color = [self._get_lines.get_next_color() for i in range(nx)]
6750+
colors = [self._get_lines.get_next_color() for i in range(nx)]
67516751
else:
6752-
color = mcolors.to_rgba_array(color)
6753-
if len(color) != nx:
6752+
colors = mcolors.to_rgba_array(color)
6753+
if len(colors) != nx:
67546754
raise ValueError(f"The 'color' keyword argument must have one "
67556755
f"color per dataset, but {nx} datasets and "
6756-
f"{len(color)} colors were provided")
6756+
f"{len(colors)} colors were provided")
67576757

67586758
hist_kwargs = dict()
67596759

@@ -6848,19 +6848,19 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
68486848
_barfunc = self.bar
68496849
bottom_kwarg = 'bottom'
68506850

6851-
for m, c in zip(tops, color):
6851+
for top, color in zip(tops, colors):
68526852
if bottom is None:
6853-
bottom = np.zeros(len(m))
6853+
bottom = np.zeros(len(top))
68546854
if stacked:
6855-
height = m - bottom
6855+
height = top - bottom
68566856
else:
6857-
height = m
6857+
height = top
68586858
bars = _barfunc(bins[:-1]+boffset, height, width,
68596859
align='center', log=log,
6860-
color=c, **{bottom_kwarg: bottom})
6860+
color=color, **{bottom_kwarg: bottom})
68616861
patches.append(bars)
68626862
if stacked:
6863-
bottom = m
6863+
bottom = top
68646864
boffset += dw
68656865
# Remove stickies from all bars but the lowest ones, as otherwise
68666866
# margin expansion would be unable to cross the stickies in the
@@ -6899,12 +6899,12 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
68996899
fill = (histtype == 'stepfilled')
69006900

69016901
xvals, yvals = [], []
6902-
for m in tops:
6902+
for top in tops:
69036903
if stacked:
69046904
# top of the previous polygon becomes the bottom
69056905
y[2*len(bins)-1:] = y[1:2*len(bins)-1][::-1]
69066906
# set the top of this polygon
6907-
y[1:2*len(bins)-1:2] = y[2:2*len(bins):2] = m + bottom
6907+
y[1:2*len(bins)-1:2] = y[2:2*len(bins):2] = top + bottom
69086908

69096909
# The starting point of the polygon has not yet been
69106910
# updated. So far only the endpoint was adjusted. This
@@ -6924,12 +6924,12 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
69246924
# add patches in reverse order so that when stacking,
69256925
# items lower in the stack are plotted on top of
69266926
# items higher in the stack
6927-
for x, y, c in reversed(list(zip(xvals, yvals, color))):
6927+
for x, y, color in reversed(list(zip(xvals, yvals, colors))):
69286928
patches.append(self.fill(
69296929
x[:split], y[:split],
69306930
closed=True if fill else None,
6931-
facecolor=c,
6932-
edgecolor=None if fill else c,
6931+
facecolor=color,
6932+
edgecolor=None if fill else color,
69336933
fill=fill if fill else None,
69346934
zorder=None if fill else mlines.Line2D.zorder))
69356935
for patch_list in patches:

0 commit comments

Comments
 (0)