Skip to content

Commit 05a26c8

Browse files
author
Moritz Schreiber
committed
remove c for bar and hbar
1 parent 5e94951 commit 05a26c8

File tree

4 files changed

+13
-36
lines changed

4 files changed

+13
-36
lines changed

pandas/plotting/_core.py

-14
Original file line numberDiff line numberDiff line change
@@ -1127,13 +1127,6 @@ def bar(self, x=None, y=None, **kwargs):
11271127
axis of the plot shows the specific categories being compared, and the
11281128
other axis represents a measured value.
11291129
"""
1130-
c = kwargs.pop("c", None)
1131-
color = kwargs.pop("color", None)
1132-
if c is not None and color is not None:
1133-
raise TypeError("Specify exactly one of `c` and `color`")
1134-
elif c is not None or color is not None:
1135-
kwargs["color"] = color if color is not None else c
1136-
11371130
return self(kind="bar", x=x, y=y, **kwargs)
11381131

11391132
@Appender(
@@ -1220,13 +1213,6 @@ def barh(self, x=None, y=None, **kwargs):
12201213
axis of the plot shows the specific categories being compared, and the
12211214
other axis represents a measured value.
12221215
"""
1223-
c = kwargs.pop("c", None)
1224-
color = kwargs.pop("color", None)
1225-
if c is not None and color is not None:
1226-
raise TypeError("Specify exactly one of `c` and `color`")
1227-
elif c is not None or color is not None:
1228-
kwargs["color"] = color if color is not None else c
1229-
12301216
return self(kind="barh", x=x, y=y, **kwargs)
12311217

12321218
def box(self, by=None, **kwargs):

pandas/tests/plotting/frame/test_frame.py

-3
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,6 @@ def test_plot_bar(self):
832832

833833
df = DataFrame({"a": [0, 1], "b": [1, 0]})
834834

835-
with pytest.raises(TypeError, match="Specify exactly one of `c` and `color`"):
836-
df.plot.bar(x="a", y="b", c="red", color="green")
837-
838835
ax = _check_plot_works(df.plot.bar)
839836
self._check_ticks_props(ax, xrot=90)
840837

pandas/tests/plotting/frame/test_frame_color.py

+11-16
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ def test_bar_colors(self):
119119
tm.close()
120120

121121
custom_colors = "rgcby"
122-
for kw in ["c", "color"]:
123-
ax = df.plot.bar(**{kw: "rgcby"})
124-
self._check_colors(ax.patches[::5], facecolors=custom_colors)
125-
tm.close()
122+
ax = df.plot.bar(color="rgcby")
123+
self._check_colors(ax.patches[::5], facecolors=custom_colors)
124+
tm.close()
126125

127126
from matplotlib import cm
128127

@@ -138,17 +137,15 @@ def test_bar_colors(self):
138137
self._check_colors(ax.patches[::5], facecolors=rgba_colors)
139138
tm.close()
140139

141-
for kw in ["c", "color"]:
142-
ax = df.loc[:, [0]].plot.bar(**{kw: "DodgerBlue"})
143-
self._check_colors([ax.patches[0]], facecolors=["DodgerBlue"])
144-
tm.close()
140+
ax = df.loc[:, [0]].plot.bar(color="DodgerBlue")
141+
self._check_colors([ax.patches[0]], facecolors=["DodgerBlue"])
142+
tm.close()
145143

146144
ax = df.plot(kind="bar", color="green")
147145
self._check_colors(ax.patches[::5], facecolors=["green"] * 5)
148146
tm.close()
149147

150-
@pytest.mark.parametrize("kw", ["c", "color"])
151-
def test_bar_user_colors(self, kw):
148+
def test_bar_user_colors(self):
152149
df = DataFrame(
153150
{"A": range(4), "B": range(1, 5), "color": ["red", "blue", "blue", "red"]}
154151
)
@@ -160,7 +157,7 @@ def test_bar_user_colors(self, kw):
160157
(0.0, 0.0, 1.0, 1.0),
161158
(1.0, 0.0, 0.0, 1.0),
162159
]
163-
ax = df.plot.bar(y="A", **{kw: df["color"]})
160+
ax = df.plot.bar(y="A", color=df["color"])
164161
result = [p.get_facecolor() for p in ax.patches]
165162
assert result == expected
166163

@@ -216,17 +213,15 @@ def test_if_scatterplot_colorbars_are_next_to_parent_axes(self):
216213
assert np.isclose(parent_distance, colorbar_distance, atol=1e-7).all()
217214

218215
@pytest.mark.parametrize("cmap", [None, "Greys"])
219-
def test_scatter_with_c_column_name_with_colors(self, cmap):
216+
@pytest.mark.parametrize("kw", ["c", "color"])
217+
def test_scatter_with_c_column_name_with_colors(self, cmap, kw):
220218
# https://github.com/pandas-dev/pandas/issues/34316
221219
df = DataFrame(
222220
[[5.1, 3.5], [4.9, 3.0], [7.0, 3.2], [6.4, 3.2], [5.9, 3.0]],
223221
columns=["length", "width"],
224222
)
225223
df["species"] = ["r", "r", "g", "g", "b"]
226-
ax = df.plot.scatter(x=0, y=1, c="species", cmap=cmap)
227-
assert ax.collections[0].colorbar is None
228-
229-
ax = df.plot.scatter(x=0, y=1, color="species", cmap=cmap)
224+
ax = df.plot.scatter(x=0, y=1, cmap=cmap, **{kw: "species"})
230225
assert ax.collections[0].colorbar is None
231226

232227
def test_scatter_colors(self):

pandas/tests/plotting/test_series.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,7 @@ def test_bar_ignore_index(self):
268268
ax = df.plot.bar(use_index=False, ax=ax)
269269
self._check_text_labels(ax.get_xticklabels(), ["0", "1", "2", "3"])
270270

271-
@pytest.mark.parametrize("kw", ["c", "color"])
272-
def test_bar_user_colors(self, kw):
271+
def test_bar_user_colors(self):
273272
s = Series([1, 2, 3, 4])
274273

275274
expected = [
@@ -279,7 +278,7 @@ def test_bar_user_colors(self, kw):
279278
(1.0, 0.0, 0.0, 1.0),
280279
]
281280

282-
ax = s.plot.bar(**{kw: ["red", "blue", "blue", "red"]})
281+
ax = s.plot.bar(color=["red", "blue", "blue", "red"])
283282
result = [p.get_facecolor() for p in ax.patches]
284283
assert result == expected
285284

0 commit comments

Comments
 (0)