You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
then I expect the colormap to be absolutely normalised according to the min and max 'z' values supplied in span. However, Datashader doesn't do this, it seems to offset the colors by the minimum value of 'z' in the data. This can be observed by dynamically zooming with bokeh, one seems the colors change rather than remain constant.
Looking at the code, I think it is because of the following lines in https://github.com/bokeh/datashader/blob/master/datashader/transfer_functions.py:
def _interpolate(agg, cmap, how, alpha, span):
if agg.ndim != 2:
raise ValueError("agg must be 2D")
interpolater = _normalize_interpolate_how(how)
data = agg.data
if np.issubdtype(data.dtype, np.bool_):
mask = ~data
interp = data
else:
if np.issubdtype(data.dtype, np.integer):
mask = data == 0
else:
mask = np.isnan(data)
masked = data[~mask]
if len(masked) == 0:
return Image(agg.data.view(np.uint32), coords=agg.coords, dims=agg.dims, attrs=agg.attrs)
offset = masked.min()
interp = data - offset
data = interpolater(interp, mask)
...
Here it seems that some offset is indeed applied according the to minimum of the dataset. I assume this is what is screwing up the interpretation of span. Probably the offset just needs to be added back in after the interpolation is applied? Anyway I tried modifying as follows:
data = interpolater(interp, mask)
---> data = interpolater(interp, mask) + offset
and it seems to produce the correct result for my case.
The text was updated successfully, but these errors were encountered:
When I use the span argument to
shade
, for example in the following callback function for Bokeh:then I expect the colormap to be absolutely normalised according to the min and max 'z' values supplied in
span
. However, Datashader doesn't do this, it seems to offset the colors by the minimum value of 'z' in the data. This can be observed by dynamically zooming with bokeh, one seems the colors change rather than remain constant.Looking at the code, I think it is because of the following lines in
https://github.com/bokeh/datashader/blob/master/datashader/transfer_functions.py
:Here it seems that some offset is indeed applied according the to minimum of the dataset. I assume this is what is screwing up the interpretation of
span
. Probably the offset just needs to be added back in after the interpolation is applied? Anyway I tried modifying as follows:data = interpolater(interp, mask)
--->
data = interpolater(interp, mask) + offset
and it seems to produce the correct result for my case.
The text was updated successfully, but these errors were encountered: