How to make no data areas different color

Hello

When plotting data on map I would like to make no data areas grey. So everything outside of area ([x, x+dw]; [y,y+dh]) would be grey.

tile_provider = get_provider(OSM)

color_mapper = LinearColorMapper(
    palette=Magma256,
    low=np.nanmin(first_plot["data"]),
    high=np.nanmax(first_plot["data"]),
    nan_color="#00000000",
)
color_bar = ColorBar(color_mapper=color_mapper, ticker=BasicTicker(), location=(0, 0))

plot = figure(
    plot_width=800,
    plot_height=800,
    tooltips=[("value", "@data")],
    x_axis_type="mercator",
    y_axis_type="mercator",
    toolbar_location="above",
)
plot.x_range.range_padding = plot.y_range.range_padding = 0
plot.add_layout(color_bar, "right")
source = ColumnDataSource(data=first_plot)
plot.add_tile(tile_provider)

image = plot.image(
    image="data",
    x="x_min",
    y="y_min",
    dw="dw",
    dh="dh",
    source=source,
    alpha=0.5,
    level="image",
    color_mapper=color_mapper,
)

layout = column(plot)
show(layout)

How could I accomplish that?
Thanks.

It’s not clear from the question, are the “no data” areas part of the image or are they outside the image?

By “no data” areas I meant area which is outside of the image.

You could add semi-unbounded BoxAnnotation around all sides of the image.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.