Custom Texture ---> hatch_scale?


Wondering if there’s a way to control the hatch_scale of a custom texture (instantiated using ImageURLTexture as suggested in the docs). Super powerful possibilities with this feature btw :slight_smile:

Minimized example:

from bokeh.models import Rect, ImageURLTexture, ColumnDataSource
from bokeh.plotting import figure,show

f = figure()

src = ColumnDataSource(data={‘x’:[1],‘y’:[1],‘w’:[1],‘h’:[1],‘texture’:[‘sand’]})
glyph = Rect(x=‘x’,y=‘y’,width=‘w’,height=‘h’,hatch_extra= {‘sand’:ImageURLTexture(url=‘’,repetition='repeat’)}
rend = f.add_glyph(src,glyph)

Thank you!


1 Like

Most of the hatch options are ignored for image textures because they just don’t really apply (e.g. what would hatch_color do? The image specifies its own colors) and this includes hatch_scale

Since almost all the canvas rendering in Bokeh synchronous except image-based things, it seems like it might add a fair amount of complication to try and have hatch_scale do anything for images. If someone wants to work on this and has a coherent user story/set of requirements, I would be willing to try to offer any relevant guidance.

1 Like

I essentially hoped that given the texture is “repeating”, I could use the hatch_scale to scale down the size of each pixel in the image (with no added “cost” because it’d simply repeat itself more)… so this grate/mesh in my example would appear much finer (in the case of a hatch_scale<1) or coarser (>1).

1 Like

Right I do think hatch_scale could be interpreted as a plain pixel scaling. But I also think the “differentness” inherent to image handling will make it not quite as trivial to implement as it would be otherwise. Certainly a reasonable GitHub Issue to submit, I just can’t speculate when it might actually get worked on.

I would also like this - my workaround is to just change the padding around the actual image.

But that’s in pixels and when the chart adjusts the size to i.e. fullscreen, the hatch pattern will just be all over the chart again.

As mentioned above a GitHub Issue is the appropriate place to start. Offhand I also think this would be a self-contained task suitable for a good first issue.

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