Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Support colorbar edgefix in non-PlotAxes
  • Loading branch information
lukelbd committed Jan 31, 2022
commit a670af1d2dcec72f479d66c45f26e52ba7e1c45d
3 changes: 2 additions & 1 deletion proplot/axes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,9 @@ def _add_colorbar(
if obj.dividers is not None:
obj.dividers.update(kw_outline)
if obj.solids:
from . import PlotAxes
obj.solids.set_rasterized(rasterized)
cax._fix_patch_edges(obj.solids, edgefix=edgefix)
PlotAxes._fix_patch_edges(obj.solids, edgefix=edgefix)

# Register location and return
self._register_guide('colorbar', obj, (loc, align)) # possibly replace another
Expand Down
37 changes: 19 additions & 18 deletions proplot/axes/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,24 @@ def _fix_contour_edges(self, method, *args, **kwargs):
kwargs['colors'] = kwargs.pop('edgecolors', 'k')
return self._plot_native(method, *args, **kwargs)

def _fix_patch_edges(self, obj, edgefix=None, **kwargs):
def _fix_sticky_edges(self, objs, axis, *args, only=None):
"""
Fix sticky edges for the input artists using the minimum and maximum of the
input coordinates. This is used to copy `bar` behavior to `area` and `lines`.
"""
for array in args:
min_, max_ = inputs._safe_range(array)
if min_ is None or max_ is None:
continue
for obj in guides._iter_iterables(objs):
if only and not isinstance(obj, only):
continue # e.g. ignore error bars
convert = getattr(self, 'convert_' + axis + 'units')
edges = getattr(obj.sticky_edges, axis)
edges.extend(convert((min_, max_)))

@staticmethod
def _fix_patch_edges(obj, edgefix=None, **kwargs):
"""
Fix white lines between between filled patches and fix issues
with colormaps that are transparent. If keyword args passed by user
Expand Down Expand Up @@ -1684,26 +1701,10 @@ def _fix_patch_edges(self, obj, edgefix=None, **kwargs):
obj.set_edgecolor(obj.get_facecolor())
elif np.iterable(obj): # e.g. silent_list of BarContainer
for element in obj:
self._fix_patch_edges(element, edgefix=edgefix)
PlotAxes._fix_patch_edges(element, edgefix=edgefix)
else:
warnings._warn_proplot(f'Unexpected obj {obj} passed to _fix_patch_edges.')

def _fix_sticky_edges(self, objs, axis, *args, only=None):
"""
Fix sticky edges for the input artists using the minimum and maximum of the
input coordinates. This is used to copy `bar` behavior to `area` and `lines`.
"""
for array in args:
min_, max_ = inputs._safe_range(array)
if min_ is None or max_ is None:
continue
for obj in guides._iter_iterables(objs):
if only and not isinstance(obj, only):
continue # e.g. ignore error bars
convert = getattr(self, 'convert_' + axis + 'units')
edges = getattr(obj.sticky_edges, axis)
edges.extend(convert((min_, max_)))

@contextlib.contextmanager
def _keep_grid_bools(self):
"""
Expand Down