Skip to content

Commit dc919b3

Browse files
authored
Merge pull request #478 from LDAP/bugfix/indexerror
Fix IndexError (#474)
2 parents 3c97861 + 32e6151 commit dc919b3

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

tikzplotlib/_path.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,22 @@ def draw_pathcollection(data, obj):
211211

212212
# "solution" from
213213
# <https://github.com/matplotlib/matplotlib/issues/4672#issuecomment-378702670>
214-
p = obj.get_paths()[0]
215-
ms = {style: MarkerStyle(style) for style in MarkerStyle.markers}
216-
paths = {
217-
style: marker.get_path().transformed(marker.get_transform())
218-
for style, marker in ms.items()
219-
}
220214
marker0 = None
221-
for marker, path in paths.items():
222-
if (
223-
np.array_equal(path.codes, p.codes)
224-
and (path.vertices.shape == p.vertices.shape)
225-
and np.max(np.abs(path.vertices - p.vertices)) < 1.0e-10
226-
):
227-
marker0 = marker
228-
break
215+
if obj.get_paths():
216+
p = obj.get_paths()[0]
217+
ms = {style: MarkerStyle(style) for style in MarkerStyle.markers}
218+
paths = {
219+
style: marker.get_path().transformed(marker.get_transform())
220+
for style, marker in ms.items()
221+
}
222+
for marker, path in paths.items():
223+
if (
224+
np.array_equal(path.codes, p.codes)
225+
and (path.vertices.shape == p.vertices.shape)
226+
and np.max(np.abs(path.vertices - p.vertices)) < 1.0e-10
227+
):
228+
marker0 = marker
229+
break
229230

230231
is_contour = len(dd) == 1
231232
if is_contour:

0 commit comments

Comments
 (0)