SultanOrazbayev
SultanOrazbayev

Reputation: 16581

Removing background color in holoviews image

What is the correct way to specify the background colour for a Holoviews image? Here's the example I am using:

import holoviews as hv
import numpy as np
hv.extension('bokeh')
eye = np.eye(10)
hv.Image(eye).opts(clipping_colors={0: 'red'})

I also tried defining clipping_colors with other values like NaN or "0", but they all give a faint blue background color as in the attached image. holoviews background color

Upvotes: 1

Views: 340

Answers (1)

James A. Bednar
James A. Bednar

Reputation: 3255

The background color is specified like .opts(bgcolor=<color>), but note that the background will only show for missing pixels, and eye here is a dense array, with no NaN values. If you want zero to be treated like missing value, then you can specify that:

import holoviews as hv
import numpy as np
hv.extension('bokeh')
eye = np.eye(10)
hv.Image(eye).opts(bgcolor="red").redim.nodata(z=0)

eye matrix with red bg

Upvotes: 1

Related Questions