When multiple images are loaded in image viewers in glue, the fixed resolution buffer logic chooses the data layer color and alpha for out-of-bounds regions. The logic passes in a "data value" of negative infinity, and sends that through the colormap. By default, this can give black out-of-bounds regions, which darkens the appearance of lower layers. In a simple example with two layers below, both layers have alpha=0.5, but the larger and lower layer is darker because the upper layer is rendered on top with black pixels at alpha=0.5.
This PR replaces -np.inf with np.nan as the default out-of-bounds value to pass into the colormap. Because of the default nan/clipping in composite_array, users shouldn't see a difference in the viewer unless they opt-in, in which case they will see:
To opt in (after this PR), select a colormap with a transparent bad pixel:
import matplotlib.pyplot as plt
cmap = plt.cm.gray.with_extremes(bad=(0, 0, 0, 0))
Description
When multiple images are loaded in image viewers in glue, the fixed resolution buffer logic chooses the data layer color and alpha for out-of-bounds regions. The logic passes in a "data value" of negative infinity, and sends that through the colormap. By default, this can give black out-of-bounds regions, which darkens the appearance of lower layers. In a simple example with two layers below, both layers have
alpha=0.5
, but the larger and lower layer is darker because the upper layer is rendered on top with black pixels at alpha=0.5.This PR replaces
-np.inf
withnp.nan
as the default out-of-bounds value to pass into the colormap. Because of the default nan/clipping incomposite_array
, users shouldn't see a difference in the viewer unless they opt-in, in which case they will see:To opt in (after this PR), select a colormap with a transparent bad pixel:
and allow the
bad
alpha to be shown (since https://github.com/glue-viz/glue/pull/2468):