Skip to content

Commit

Permalink
Improve default zorder for auto-added contour labels
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Sep 21, 2021
1 parent d101575 commit 5922216
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions proplot/axes/plot.py
Expand Up @@ -1481,9 +1481,14 @@ def _add_contour_labels(
_, _, lum = utils.to_xyz(obj.cmap(obj.norm(level)))
colors.append('w' if lum < 50 else 'k')

# Draw labels
# Draw labels with careful zorder
# Want to at least match text zorder but respect contour zorder
zorder = max(h.get_zorder() for h in obj.collections)
zorder = max(3, zorder + 1)
kwargs.setdefault('zorder', zorder)
labs = cobj.clabel(
fmt=fmt, colors=colors, fontsize=fontsize, inline_spacing=inline_spacing, **kwargs # noqa: E501
fmt=fmt, colors=colors, fontsize=fontsize,
inline_spacing=inline_spacing, **kwargs
)
if labs is not None: # returns None if no contours
for lab in labs:
Expand All @@ -1492,7 +1497,8 @@ def _add_contour_labels(
return labs

def _add_gridbox_labels(
self, obj, fmt, *, c=None, color=None, colors=None, size=None, fontsize=None, **kwargs # noqa: E501
self, obj, fmt, *, c=None, color=None, colors=None,
size=None, fontsize=None, **kwargs
):
"""
Add labels to pcolor boxes with support for shade-dependent text colors.
Expand Down

0 comments on commit 5922216

Please sign in to comment.