Skip to content

Fixes passing marker=None into scale #3301

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions seaborn/_marks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pandas import DataFrame
from matplotlib.artist import Artist

from seaborn._compat import MarkerStyle
from seaborn._core.scales import Scale
from seaborn._core.properties import (
PROPERTIES,
Expand Down Expand Up @@ -182,6 +183,8 @@ def _resolve(

if return_array:
feature = np.asarray(feature)
if name == "marker":
feature = [MarkerStyle(f) for f in feature]
return feature

if feature.depend is not None:
Expand Down
30 changes: 21 additions & 9 deletions tests/_marks/test_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from numpy.testing import assert_array_equal

from seaborn.palettes import color_palette
from seaborn._core.plot import Plot
from seaborn._core.plot import Plot, Plotter
from seaborn._marks.dot import Dot, Dots


Expand Down Expand Up @@ -53,15 +53,16 @@ def test_filled_unfilled_mix(self):

mark = Dot(edgecolor="w", stroke=2, edgewidth=1)
p = Plot(x=x, y=y).add(mark, marker=marker).scale(marker=shapes).plot()
ax = p._figure.axes[0]
points, = ax.collections
C0, *_ = p._theme["axes.prop_cycle"].by_key()["color"]
self.check_offsets(points, x, y)
self.check_colors("face", points, [C0, to_rgba(C0, 0)], None)
self.check_colors("edge", points, ["w", C0], 1)
self._test_filled_unfilled_mix(x, y, p, mark)

expected = [mark.edgewidth, mark.stroke]
assert_array_equal(points.get_linewidths(), expected)
def test_identity_marker(self):
x = [1, 2]
y = [4, 5]
shapes = ["o", "x"]

mark = Dot(edgecolor="w", stroke=2, edgewidth=1)
p = Plot(x=x, y=y).add(mark, marker=shapes).scale(marker=None).plot()
self._test_filled_unfilled_mix(x, y, p, mark)

def test_missing_coordinate_data(self):

Expand All @@ -85,6 +86,17 @@ def test_missing_semantic_data(self, prop):
points, = ax.collections
self.check_offsets(points, [1, 3], [5, 4])

def _test_filled_unfilled_mix(self, x, y, p: Plotter, mark: Dot):
ax = p._figure.axes[0]
points, = ax.collections
C0, *_ = p._theme["axes.prop_cycle"].by_key()["color"]
self.check_offsets(points, x, y)
self.check_colors("face", points, [C0, to_rgba(C0, 0)], None)
self.check_colors("edge", points, ["w", C0], 1)

expected = [mark.edgewidth, mark.stroke]
assert_array_equal(points.get_linewidths(), expected)


class TestDots(DotBase):

Expand Down