Skip to content

BUG: addresses #14855 by fixing color kwarg conflict #14871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -975,3 +975,4 @@ Bug Fixes
- Bug in ``pd.melt()`` where passing a tuple value for ``value_vars`` caused a ``TypeError`` (:issue:`15348`)
- Bug in ``.eval()`` which caused multiline evals to fail with local variables not on the first line (:issue:`15342`)
- Bug in ``pd.read_msgpack`` which did not allow to load dataframe with an index of type ``CategoricalIndex`` (:issue:`15487`)
- Bug in ``pd.scatter_matrix()`` could accept either ``color`` or ``c``, but not both (:issue:`14855`)
6 changes: 6 additions & 0 deletions pandas/tests/plotting/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def scat(**kwds):
_check_plot_works(scat, diagonal='hist')
with tm.assert_produces_warning(UserWarning):
_check_plot_works(scat, range_padding=.1)
with tm.assert_produces_warning(UserWarning):
_check_plot_works(scat, color='rgb')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you pass here 'rgb' and not just 'r'? As passing multiple colors seems a bit odd for a single scatter plot (I think now the points just get the [r, g, b, r, g, b, r, g, b, ...] colors sequentially?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purely for aesthetic purposes. I have trouble seeing some colors and wanted to visually confirm these changes rendered the same objects.

with tm.assert_produces_warning(UserWarning):
_check_plot_works(scat, c='rgb')
with tm.assert_produces_warning(UserWarning):
_check_plot_works(scat, facecolor='rgb')

def scat2(x, y, by=None, ax=None, figsize=None):
return plotting.scatter_plot(df, x, y, by, ax, figsize=None)
Expand Down
8 changes: 3 additions & 5 deletions pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ def scatter_matrix(frame, alpha=0.5, figsize=None, ax=None, grid=False,
>>> df = DataFrame(np.random.randn(1000, 4), columns=['A','B','C','D'])
>>> scatter_matrix(df, alpha=0.2)
"""
import matplotlib.pyplot as plt

df = frame._get_numeric_data()
n = df.columns.size
Expand All @@ -367,8 +366,8 @@ def scatter_matrix(frame, alpha=0.5, figsize=None, ax=None, grid=False,
hist_kwds = hist_kwds or {}
density_kwds = density_kwds or {}

# workaround because `c='b'` is hardcoded in matplotlibs scatter method
kwds.setdefault('c', plt.rcParams['patch.facecolor'])
# GH 14855
kwds.setdefault('edgecolors', 'none')

boundaries_list = []
for a in df.columns:
Expand Down Expand Up @@ -2864,8 +2863,7 @@ def scatter_plot(data, x, y, by=None, ax=None, figsize=None, grid=False,
"""
import matplotlib.pyplot as plt

# workaround because `c='b'` is hardcoded in matplotlibs scatter method
kwargs.setdefault('c', plt.rcParams['patch.facecolor'])
kwargs.setdefault('edgecolors', 'none')

def plot_group(group, ax):
xvals = group[x].values
Expand Down