Skip to content

Commit caf36aa

Browse files
committed
fix for draw options
1 parent 8fec937 commit caf36aa

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

test/test_contourf.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@ def test():
3232

3333

3434
if __name__ == "__main__":
35-
plot()
36-
plt.show()
35+
# plot()
36+
# plt.show()
3737
# import helpers
38-
3938
# helpers.compare_mpl_tex(plot)
4039
# helpers.print_tree(plot())
40+
plot()
41+
import matplotlib.pyplot as plt
42+
43+
# plt.show()
44+
# plt.savefig('out.pgf')
45+
import tikzplotlib
46+
47+
tikzplotlib.save("out.tex", standalone=True)

tikzplotlib/_path.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,15 @@ def draw_pathcollection(data, obj):
140140

141141
try:
142142
ec = obj.get_edgecolors()
143-
except (TypeError, IndexError):
143+
except TypeError:
144144
ec = None
145145
else:
146-
if len(ec) == 1:
146+
if len(ec) == 0:
147+
ec = None
148+
elif len(ec) == 1:
147149
ec = ec[0]
148150
else:
151+
print(ec)
149152
assert len(ec) == len(dd)
150153
labels.append("draw" + 3 * " ")
151154
ec_strings = [
@@ -154,13 +157,16 @@ def draw_pathcollection(data, obj):
154157
]
155158
dd_strings = np.column_stack([dd_strings, ec_strings])
156159
add_individual_color_code = True
160+
ec = None
157161

158162
try:
159163
fc = obj.get_facecolors()
160-
except (TypeError, IndexError):
164+
except TypeError:
161165
fc = None
162166
else:
163-
if len(fc) == 1:
167+
if len(fc) == 0:
168+
fc = None
169+
elif len(fc) == 1:
164170
fc = fc[0]
165171
else:
166172
assert len(fc) == len(dd)
@@ -171,6 +177,7 @@ def draw_pathcollection(data, obj):
171177
]
172178
dd_strings = np.column_stack([dd_strings, fc_strings])
173179
add_individual_color_code = True
180+
fc = None
174181

175182
try:
176183
ls = obj.get_linestyle()[0]
@@ -225,14 +232,7 @@ def draw_pathcollection(data, obj):
225232
draw_options += ["mark options={{{}}}".format(",".join(marker_options))]
226233

227234
# `only mark` plots don't need linewidth
228-
data, extra_draw_options = get_draw_options(
229-
data,
230-
obj,
231-
None if ec is None or len(ec) > 1 else ec,
232-
None if fc is None or len(fc) > 1 else fc,
233-
ls,
234-
None,
235-
)
235+
data, extra_draw_options = get_draw_options(data, obj, ec, fc, ls, None)
236236
draw_options += extra_draw_options
237237

238238
if obj.get_cmap():
@@ -246,6 +246,7 @@ def draw_pathcollection(data, obj):
246246
for path in obj.get_paths():
247247
if is_contour:
248248
dd = path.vertices
249+
dd_strings = np.array([[fmt.format(val) for val in row] for row in dd])
249250

250251
if len(obj.get_sizes()) == len(dd):
251252
# See Pgfplots manual, chapter 4.25.
@@ -298,8 +299,7 @@ def get_draw_options(data, obj, ec, fc, ls, lw, hatch=None):
298299
lw - linewidth
299300
hatch=None - hatch, i.e., pattern within closed path
300301
Output:
301-
draw_options - list, to be ",".join(draw_options) to produce the
302-
draw options passed to PGF
302+
draw_options - list
303303
"""
304304
draw_options = []
305305

0 commit comments

Comments
 (0)