Skip to content

Commit 49ca155

Browse files
committed
scatter: marker fill fix
1 parent cf25e5a commit 49ca155

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

tikzplotlib/_line2d.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ def draw_line2d(data, obj):
6262

6363
marker_face_color = obj.get_markerfacecolor()
6464
marker_edge_color = obj.get_markeredgecolor()
65+
66+
is_filled = marker_face_color is not None and not (
67+
isinstance(marker_face_color, str) and marker_face_color.lower() == "none"
68+
)
6569
data, marker, extra_mark_options = _mpl_marker2pgfp_marker(
66-
data, obj.get_marker(), marker_face_color
70+
data, obj.get_marker(), is_filled
6771
)
6872
if marker:
6973
_marker(

tikzplotlib/_markers.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838

3939

40-
def _mpl_marker2pgfp_marker(data, mpl_marker, marker_face_color):
40+
def _mpl_marker2pgfp_marker(data, mpl_marker: str, is_filled: bool):
4141
"""Translates a marker style of matplotlib to the corresponding style
4242
in PGFPlots.
4343
"""
@@ -47,7 +47,7 @@ def _mpl_marker2pgfp_marker(data, mpl_marker, marker_face_color):
4747
except KeyError:
4848
pass
4949
else:
50-
if (marker_face_color is not None) and pgfplots_marker == "o":
50+
if is_filled and pgfplots_marker == "o":
5151
pgfplots_marker = "*"
5252
data["tikz libs"].add("plotmarks")
5353
marker_options = []
@@ -61,14 +61,7 @@ def _mpl_marker2pgfp_marker(data, mpl_marker, marker_face_color):
6161
# There's no equivalent for the pixel marker (,) in Pgfplots.
6262
pass
6363
else:
64-
if (
65-
marker_face_color is not None
66-
and (
67-
not isinstance(marker_face_color, str)
68-
or marker_face_color.lower() != "none"
69-
)
70-
and pgfplots_marker not in ["|", "-", "asterisk", "star"]
71-
):
64+
if is_filled and pgfplots_marker not in ["|", "-", "asterisk", "star"]:
7265
pgfplots_marker += "*"
7366
return data, pgfplots_marker, marker_options
7467

tikzplotlib/_path.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def draw_pathcollection(data, obj):
124124
draw_options = ["scatter", "only marks"]
125125
table_options = []
126126

127+
is_filled = False
128+
127129
if obj.get_array() is not None:
128130
draw_options.append("scatter")
129131
dd_strings = np.column_stack([dd_strings, obj.get_array()])
@@ -153,7 +155,6 @@ def draw_pathcollection(data, obj):
153155
elif len(ec) == 1:
154156
ec = ec[0]
155157
else:
156-
print(ec)
157158
assert len(ec) == len(dd)
158159
labels.append("draw")
159160
ec_strings = [
@@ -173,6 +174,7 @@ def draw_pathcollection(data, obj):
173174
fc = None
174175
elif len(fc) == 1:
175176
fc = fc[0]
177+
is_filled = True
176178
else:
177179
assert len(fc) == len(dd)
178180
labels.append("fill")
@@ -183,6 +185,7 @@ def draw_pathcollection(data, obj):
183185
dd_strings = np.column_stack([dd_strings, fc_strings])
184186
add_individual_color_code = True
185187
fc = None
188+
is_filled = True
186189

187190
try:
188191
ls = obj.get_linestyle()[0]
@@ -230,7 +233,7 @@ def draw_pathcollection(data, obj):
230233

231234
if marker0 is not None:
232235
data, pgfplots_marker, marker_options = _mpl_marker2pgfp_marker(
233-
data, marker0, fc
236+
data, marker0, is_filled
234237
)
235238
draw_options += [f"mark={pgfplots_marker}"]
236239
if marker_options:

0 commit comments

Comments
 (0)