Skip to content

Fix scatter norm keyword #45966

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

Merged
merged 13 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ def _make_plot(self):
bounds = np.linspace(0, n_cats, n_cats + 1)
norm = colors.BoundaryNorm(bounds, cmap.N)
else:
norm = None
norm = self.kwds.pop("norm", None)
# plot colorbar if
# 1. colormap is assigned, and
# 2.`c` is a column containing only numeric values
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/plotting/frame/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,18 @@ def test_plot_scatter_with_s(self):
ax = df.plot.scatter(x="a", y="b", s="c")
tm.assert_numpy_array_equal(df["c"].values, right=ax.collections[0].get_sizes())

def test_plot_scatter_with_norm(self):
# added while fixing GH 45809
import matplotlib as mpl

ax = self.hexbin_df.plot.scatter(x="A", y="B", c="C", norm=mpl.colors.LogNorm())
assert ax.collections[0].norm._scale

def test_plot_scatter_without_norm(self):
# added while fixing GH 45809
ax = self.hexbin_df.plot.scatter(x="A", y="B", c="C")
assert ax.collections[0].norm._scale is None

def test_plot_bar(self):
df = DataFrame(
np.random.randn(6, 4),
Expand Down