Skip to content

Commit a670af1

Browse files
committed
Support colorbar edgefix in non-PlotAxes
1 parent fabb5ff commit a670af1

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

proplot/axes/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,9 @@ def _add_colorbar(
11751175
if obj.dividers is not None:
11761176
obj.dividers.update(kw_outline)
11771177
if obj.solids:
1178+
from . import PlotAxes
11781179
obj.solids.set_rasterized(rasterized)
1179-
cax._fix_patch_edges(obj.solids, edgefix=edgefix)
1180+
PlotAxes._fix_patch_edges(obj.solids, edgefix=edgefix)
11801181

11811182
# Register location and return
11821183
self._register_guide('colorbar', obj, (loc, align)) # possibly replace another

proplot/axes/plot.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,24 @@ def _fix_contour_edges(self, method, *args, **kwargs):
16351635
kwargs['colors'] = kwargs.pop('edgecolors', 'k')
16361636
return self._plot_native(method, *args, **kwargs)
16371637

1638-
def _fix_patch_edges(self, obj, edgefix=None, **kwargs):
1638+
def _fix_sticky_edges(self, objs, axis, *args, only=None):
1639+
"""
1640+
Fix sticky edges for the input artists using the minimum and maximum of the
1641+
input coordinates. This is used to copy `bar` behavior to `area` and `lines`.
1642+
"""
1643+
for array in args:
1644+
min_, max_ = inputs._safe_range(array)
1645+
if min_ is None or max_ is None:
1646+
continue
1647+
for obj in guides._iter_iterables(objs):
1648+
if only and not isinstance(obj, only):
1649+
continue # e.g. ignore error bars
1650+
convert = getattr(self, 'convert_' + axis + 'units')
1651+
edges = getattr(obj.sticky_edges, axis)
1652+
edges.extend(convert((min_, max_)))
1653+
1654+
@staticmethod
1655+
def _fix_patch_edges(obj, edgefix=None, **kwargs):
16391656
"""
16401657
Fix white lines between between filled patches and fix issues
16411658
with colormaps that are transparent. If keyword args passed by user
@@ -1684,26 +1701,10 @@ def _fix_patch_edges(self, obj, edgefix=None, **kwargs):
16841701
obj.set_edgecolor(obj.get_facecolor())
16851702
elif np.iterable(obj): # e.g. silent_list of BarContainer
16861703
for element in obj:
1687-
self._fix_patch_edges(element, edgefix=edgefix)
1704+
PlotAxes._fix_patch_edges(element, edgefix=edgefix)
16881705
else:
16891706
warnings._warn_proplot(f'Unexpected obj {obj} passed to _fix_patch_edges.')
16901707

1691-
def _fix_sticky_edges(self, objs, axis, *args, only=None):
1692-
"""
1693-
Fix sticky edges for the input artists using the minimum and maximum of the
1694-
input coordinates. This is used to copy `bar` behavior to `area` and `lines`.
1695-
"""
1696-
for array in args:
1697-
min_, max_ = inputs._safe_range(array)
1698-
if min_ is None or max_ is None:
1699-
continue
1700-
for obj in guides._iter_iterables(objs):
1701-
if only and not isinstance(obj, only):
1702-
continue # e.g. ignore error bars
1703-
convert = getattr(self, 'convert_' + axis + 'units')
1704-
edges = getattr(obj.sticky_edges, axis)
1705-
edges.extend(convert((min_, max_)))
1706-
17071708
@contextlib.contextmanager
17081709
def _keep_grid_bools(self):
17091710
"""

0 commit comments

Comments
 (0)