Yasir Azeem
Yasir Azeem

Reputation: 329

Datashader image not rendering when zoom in bokeh plots

Here is my code:

x_range = (0, len(df))
y_range = (df['EuPrice'].min(), df['EuPrice'].max())
def create_image(x_range, y_range, w, h):
    cvs = ds.Canvas(plot_width=w, plot_height=w//1.2)
    agg = cvs.line(df, 'fakedata', 'EuPrice')
    img = tf.shade(agg)
    return img

def base_plot(tools='pan,wheel_zoom,box_zoom,resize,reset'):
    p = bp.figure(tools=tools, plot_width=600, plot_height=300,
        x_range=x_range, y_range=y_range, outline_line_color=None,
        min_border=0, min_border_left=0, min_border_right=0,
        min_border_top=0, min_border_bottom=0)   
    p.xgrid.grid_line_color = None
    p.ygrid.grid_line_color = None
    return p

p = base_plot()
InteractiveImage(p, create_image)

Problem is that it loads the plot from datashader into bokeh plot interface. But when I zoom the image, only axis values change, but the plot image returns to the same point when I try to zoom the data. Zooms in a bit but then back to full stack of data view.

[Needless to say I am quite new in learning these libraries]

Upvotes: 2

Views: 627

Answers (1)

James A. Bednar
James A. Bednar

Reputation: 3255

You need to propagate the x_range and y_range from Bokeh all the way down to the datashader level:

cvs = ds.Canvas(plot_width=w, plot_height=w//1.2, x_range=x_range, y_range=y_range)

Upvotes: 1

Related Questions