Using band_hatch_pattern with images

Hi,
I’m trying to use hatch_patterns as watermarks. It works for i.e. vbars, but it might be better if it were used in a band_hatch.

So, this works:

from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.models import ImageURLTexture
import panel as pn
import holoviews as hv
import numpy as np

hv.extension('bokeh')

pn.extension()

p = figure(height=250, width=600)
p.vbar(x=[0],
       top=[1],
       alpha=0.2,
       hatch_extra={ 'mycustom': ImageURLTexture(url='https://miro.medium.com/fit/c/262/262/2*hYgXkcU-IzRzAGrw4kN5lQ.png') },
       hatch_pattern = dict(value="mycustom"),hatch_scale=12
      )

pn.Column(p)

image

But this does not:

from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.models import ImageURLTexture
import panel as pn
import holoviews as hv
import numpy as np

hv.extension('bokeh')

pn.extension()

p = figure(height=250, width=600)
p.vbar(x=[0],
       top=[1],
       alpha=0.2,
#        hatch_extra={ 'mycustom': ImageURLTexture(url='https://miro.medium.com/fit/c/262/262/2*hYgXkcU-IzRzAGrw4kN5lQ.png') },
#        hatch_pattern = dict(value="mycustom"),hatch_scale=12
      )

p.xgrid.band_hatch_extra={ 'mycustom': ImageURLTexture(url='https://miro.medium.com/fit/c/262/262/2*hYgXkcU-IzRzAGrw4kN5lQ.png') }
p.xgrid.band_hatch_pattern = 'mycustom'

pn.Column(p)

image

Using '/' as hatch_pattern, you get this:
image

Am I doing it wrong or do band_hatch_patterns just not support images?

I don’t know that this specific combination of usage has ever been explicitly considered. Are there any errors reported in the browser’s JavaScript console?

Edit: also please always include version information in all support questions, so that others can actually try your code in the same context.

No errors in the console apart from the missing favicon if I serve it as an app.

Package info:
bokeh: 2.3.3
panel: 0.12.0
*but it also doesn’t work with 2.4.0 & 0.12.2

All I can suggest at this point is to file a bug report GitHub Issue with these details.

1 Like

OK - I was just unsure if this was really a bug or if I didn’t use it properly.

Bug report:

1 Like

PR to fix:

Lands on branch-3.0 but we will back port it to a 2.4.1 to be released much sooner than that.

1 Like

Awesome, thank you!

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