tilesholoviewsdatashaderhvplotgeoviews

When using rasterize=True with datashader, how do I get transparency where count=0 to see the underlying tile?


Currently, when I do this:

import pandas as pd
import hvplot.pandas

df = pd.util.testing.makeDataFrame()
plot = df.hvplot.points('A', 'B', tiles=True, rasterize=True, geo=True,
                        aggregator='count')

I can't see the underlying tile source.

enter image description here


Solution

  • To see the underlying tile source philippjfr suggested setting the color bar limits slightly higher than 0 and set the min clipping_colors to transparent:

    plot = plot.redim.range(**{'Count': (0.25, 1)})
    plot = plot.opts('Image', clipping_colors={'min': 'transparent'})
    

    Now the underlying tile source is viewable.

    enter image description here

    Full Code:

    import pandas as pd
    import hvplot.pandas
    
    df = pd.util.testing.makeDataFrame()
    plot = df.hvplot.points('A', 'B', tiles=True, rasterize=True, geo=True,
                            aggregator='count')
    
    plot = plot.redim.range(**{'Count': (0.25, 1)})
    plot = plot.opts('Image', clipping_colors={'min': 'transparent'})
    plot