Skip to content

Commit 3feaabc

Browse files
authored
Rework after comments
1 parent 2f54813 commit 3feaabc

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

pandas/plotting/_core.py

+35-6
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,13 @@ 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+
if c is not None or color is not None:
1135+
kwargs.setdefault('c', color or c)
1136+
11301137
return self(kind="bar", x=x, y=y, **kwargs)
11311138

11321139
@Appender(
@@ -1213,6 +1220,13 @@ def barh(self, x=None, y=None, **kwargs):
12131220
axis of the plot shows the specific categories being compared, and the
12141221
other axis represents a measured value.
12151222
"""
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+
if c is not None or color is not None:
1228+
kwargs.setdefault('c', color or c)
1229+
12161230
return self(kind="barh", x=x, y=y, **kwargs)
12171231

12181232
def box(self, by=None, **kwargs):
@@ -1582,7 +1596,7 @@ def pie(self, **kwargs):
15821596
raise ValueError("pie requires either y column or 'subplots=True'")
15831597
return self(kind="pie", **kwargs)
15841598

1585-
def scatter(self, x, y, size=None, s=None, color=None, c=None, **kwargs):
1599+
def scatter(self, x, y, **kwargs):
15861600
"""
15871601
Create a scatter plot with varying marker point size and color.
15881602
@@ -1601,7 +1615,7 @@ def scatter(self, x, y, size=None, s=None, color=None, c=None, **kwargs):
16011615
y : int or str
16021616
The column name or column position to be used as vertical
16031617
coordinates for each point.
1604-
size : str, scalar or array-like, optional
1618+
s : str, scalar or array-like, optional
16051619
The size of each point. Possible values are:
16061620
16071621
- A string with the name of the column to be used for marker's size.
@@ -1614,7 +1628,7 @@ def scatter(self, x, y, size=None, s=None, color=None, c=None, **kwargs):
16141628
16151629
.. versionchanged:: 1.1.0
16161630
1617-
color : str, int or array-like, optional
1631+
c : str, int or array-like, optional
16181632
The color of each point. Possible values are:
16191633
16201634
- A single color string referred to by name, RGB or RGBA code,
@@ -1653,7 +1667,7 @@ def scatter(self, x, y, size=None, s=None, color=None, c=None, **kwargs):
16531667
... columns=['length', 'width', 'species'])
16541668
>>> ax1 = df.plot.scatter(x='length',
16551669
... y='width',
1656-
... color='DarkBlue')
1670+
... c='DarkBlue')
16571671
16581672
And now with the color determined by a column as well.
16591673
@@ -1662,10 +1676,25 @@ def scatter(self, x, y, size=None, s=None, color=None, c=None, **kwargs):
16621676
16631677
>>> ax2 = df.plot.scatter(x='length',
16641678
... y='width',
1665-
... color='species',
1679+
... c='species',
16661680
... colormap='viridis')
16671681
"""
1668-
return self(kind="scatter", x=x, y=y, s=size or s, c=color or c, **kwargs)
1682+
1683+
s = kwargs.pop('s', None)
1684+
size = kwargs.pop('size', None)
1685+
if s is not None and size is not None:
1686+
raise TypeError("Specify exactly one of `s` and `size`")
1687+
if s is not None or size is not None:
1688+
kwargs.setdefault('s', s or size)
1689+
1690+
c = kwargs.pop('c', None)
1691+
color = kwargs.pop('color', None)
1692+
if c is not None and color is not None:
1693+
raise TypeError("Specify exactly one of `c` and `color`")
1694+
if c is not None or color is not None:
1695+
kwargs.setdefault('c', c or color)
1696+
1697+
return self(kind="scatter", x=x, y=y, **kwargs)
16691698

16701699
def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None, **kwargs):
16711700
"""

0 commit comments

Comments
 (0)