Skip to content

Commit

Permalink
fix bug where mpl v>=3 drew multiple labels per item
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Jul 11, 2019
1 parent 06c3bb0 commit b6c173c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions autofig/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ def _to_linebreak_list(thing, N=1):
cs = _to_linebreak_list(c, linebreak_n)
ss = _to_linebreak_list(s, linebreak_n)

for x,xerr,y,yerr,z,c,s in zip(xs, xerrs, ys, yerrs, zs, cs, ss):
for loop1,(x,xerr,y,yerr,z,c,s) in enumerate(zip(xs, xerrs, ys, yerrs, zs, cs, ss)):
if axes_3d:
data = np.array([x, y, z])
points = np.array([x, y, z]).T.reshape(-1, 1, 3)
Expand Down Expand Up @@ -1203,15 +1203,15 @@ def sc_kwargs_loop(sc_kwargs, loop, do_zorder):
zorders = [zorders]
segments = [segments]

for loop, (datapoint, segment, zorder) in enumerate(zip(datas, segments, zorders)):
for loop2, (datapoint, segment, zorder) in enumerate(zip(datas, segments, zorders)):
return_artists_this_loop = []
# DRAW ERRORBARS, if applicable
if xerr is not None or yerr is not None or zerr is not None:
artists = ax.errorbar(*datapoint,
fmt='', linestyle='None',
zorder=zorder,
label=self.label if loop==0 else None,
**error_kwargs_loop(xerr, yerr, zerr, loop, do_zorder))
label=self.label if loop1==0 and loop2==0 else None,
**error_kwargs_loop(xerr, yerr, zerr, loop2, do_zorder))

# NOTE: these are currently not included in return_artists
# so they don't scale according to per-element sizes.
Expand Down Expand Up @@ -1249,12 +1249,12 @@ def sc_kwargs_loop(sc_kwargs, loop, do_zorder):
# marker and linestyle are present
lc = lccall(segments,
zorder=zorder,
label=self.label if loop==0 and marker.lower()=='none' else None,
**lc_kwargs_loop(lc_kwargs_const, loop, do_zorder))
label=self.label if loop1==0 and loop2==0 and marker.lower()=='none' else None,
**lc_kwargs_loop(lc_kwargs_const, loop2, do_zorder))

if do_colorscale:
if do_zorder:
lc.set_array(np.array([c[loop]]))
lc.set_array(np.array([c[loop2]]))
else:
lc.set_array(c)

Expand All @@ -1267,8 +1267,8 @@ def sc_kwargs_loop(sc_kwargs, loop, do_zorder):
if marker.lower() != 'none':
artist = ax.scatter(*datapoint,
zorder=zorder,
label=self.label if loop==0 else None,
**sc_kwargs_loop(sc_kwargs_const, loop, do_zorder))
label=self.label if loop1==0 and loop2==0 else None,
**sc_kwargs_loop(sc_kwargs_const, loop2, do_zorder))

return_artists_this_loop.append(artist)

Expand All @@ -1281,11 +1281,11 @@ def sc_kwargs_loop(sc_kwargs, loop, do_zorder):
ls=ls,
mec='none',
color=color,
label=self.label if loop==0 else None)
label=self.label if loop1==0 and loop2==0 else None)

return_artists_this_loop += artists

size_this_loop = sizes_loop(loop, do_zorder)
size_this_loop = sizes_loop(loop2, do_zorder)
for artist in return_artists_this_loop:
# store the sizes so they can be rescaled appropriately by
# the callback
Expand Down Expand Up @@ -1805,13 +1805,13 @@ def draw(self, ax=None, i=None,
if isinstance(facecolors, str):
facecolors = [facecolors] * len(zorders)

for polygon, zorder, edgecolor, facecolor in zip(polygons, zorders, edgecolors, facecolors):
for loop, (polygon, zorder, edgecolor, facecolor) in enumerate(zip(polygons, zorders, edgecolors, facecolors)):
pc = pccall((polygon,),
linestyle=self.linestyle,
edgecolors=edgecolor,
facecolors=facecolor,
zorder=zorder,
label=self.label)
label=self.label if loop==0 else None)
ax.add_collection(pc)

return_artists += [pc]
Expand Down

0 comments on commit b6c173c

Please sign in to comment.