Skip to content

Commit cf25e5a

Browse files
committed
another fix for paths
1 parent caf36aa commit cf25e5a

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

tikzplotlib/_path.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def draw_pathcollection(data, obj):
115115
content = []
116116
# gather data
117117
assert obj.get_offsets() is not None
118-
labels = ["x" + 3 * " ", "y" + 3 * " "]
118+
labels = ["x", "y"]
119119
dd = obj.get_offsets()
120120

121121
fmt = "{:" + data["float format"] + "}"
@@ -126,14 +126,19 @@ def draw_pathcollection(data, obj):
126126

127127
if obj.get_array() is not None:
128128
draw_options.append("scatter")
129-
dd = np.column_stack([dd, obj.get_array()])
130-
labels.append("colordata" + 13 * " ")
129+
dd_strings = np.column_stack([dd_strings, obj.get_array()])
130+
labels.append("colordata")
131131
draw_options.append("scatter src=explicit")
132132
table_options.extend(["x=x", "y=y", "meta=colordata"])
133133
ec = None
134134
fc = None
135135
ls = None
136136
marker0 = None
137+
if obj.get_cmap():
138+
mycolormap, is_custom_cmap = _mpl_cmap2pgf_cmap(obj.get_cmap(), data)
139+
draw_options.append(
140+
"colormap" + ("=" if is_custom_cmap else "/") + mycolormap
141+
)
137142
else:
138143
# gather the draw options
139144
add_individual_color_code = False
@@ -150,7 +155,7 @@ def draw_pathcollection(data, obj):
150155
else:
151156
print(ec)
152157
assert len(ec) == len(dd)
153-
labels.append("draw" + 3 * " ")
158+
labels.append("draw")
154159
ec_strings = [
155160
",".join(fmt.format(item) for item in row)
156161
for row in ec[:, :3] * 255
@@ -170,7 +175,7 @@ def draw_pathcollection(data, obj):
170175
fc = fc[0]
171176
else:
172177
assert len(fc) == len(dd)
173-
labels.append("fill" + 3 * " ")
178+
labels.append("fill")
174179
fc_strings = [
175180
",".join(fmt.format(item) for item in row)
176181
for row in fc[:, :3] * 255
@@ -235,10 +240,6 @@ def draw_pathcollection(data, obj):
235240
data, extra_draw_options = get_draw_options(data, obj, ec, fc, ls, None)
236241
draw_options += extra_draw_options
237242

238-
if obj.get_cmap():
239-
mycolormap, is_custom_cmap = _mpl_cmap2pgf_cmap(obj.get_cmap(), data)
240-
draw_options.append("colormap" + ("=" if is_custom_cmap else "/") + mycolormap)
241-
242243
legend_text = get_legend_text(obj)
243244
if legend_text is None and has_legend(obj.axes):
244245
draw_options.append("forget plot")
@@ -252,8 +253,8 @@ def draw_pathcollection(data, obj):
252253
# See Pgfplots manual, chapter 4.25.
253254
# In Pgfplots, \mark size specifies radii, in matplotlib circle areas.
254255
radii = np.sqrt(obj.get_sizes() / np.pi)
255-
dd = np.column_stack([dd, radii])
256-
labels.append("sizedata" + 14 * " ")
256+
dd_strings = np.column_stack([dd_strings, radii])
257+
labels.append("sizedata")
257258
draw_options.extend(
258259
[
259260
"visualization depends on="
@@ -274,7 +275,7 @@ def draw_pathcollection(data, obj):
274275
to = " [{}]".format(", ".join(table_options)) if table_options else ""
275276
content.append(f"table{to}{{%\n")
276277

277-
content.append((" ".join(labels)).strip() + "\n")
278+
content.append(" ".join(labels) + "\n")
278279
ff = data["float format"]
279280

280281
for row in dd_strings:

0 commit comments

Comments
 (0)