Open maximlt opened 2 years ago
Hello,
Is there an equivalent way to work around this bug if the Image is RGB (https://hvplot.holoviz.org/reference/xarray/rgb.html)? For example, I have an image time-series visualized with hvplot.rgb and the zoom resets when image slider for time is moved.
tsPlot = imgCube.hvplot.rgb(x = 'x',
y = 'y',
bands = 'band',
data_aspect = 1,
frame_width = 600,
yaxis = None,
xaxis = None).opts(tools = ['crosshair'])
This works great (imgCube is an xarray.DataArray with 3 bands and various number of steps in time/x/y dimensions) and displays within a second or two even for large/long time-series - the only issue I have is with the zoom resetting described in this Issue.
I could not work out an equivalent set up to your second example with dataset.to(hv.Image ...) using hv.RGB instead. I found this example (https://stackoverflow.com/questions/60613662/holoviews-how-to-wrap-multiple-rgb-images-into-a-dataset-and-display-them-corre) that could work in theory, but it is very slow if the time-series has hundreds of images.
Thanks for your great work on this package!
To not update the axis in the original example, you can set
In the original example, the reset can be stopped by .opts(framewise=False)
. I would assume that would also be the case for RGB
.
That worked great, thanks for the quick response!
Is this really a bug? Maybe setting up framewise = False
by default would solve it?
This is not working for me, though the API I'm using is slightly different:
#!/usr/bin/env python3
# Very basic test with hvplot and fake data
import panel as pn
import xarray as xr
import hvplot.xarray
import hvplot
import numpy as np
import holoviews as hv
shape = (20, 100, 100)
dst = xr.Dataset(
{
'image': (['time', 'x', 'y'], np.random.random((5, 10, 10))),
'profile': (['time', 'r'], np.random.random((5, 10)))
},
coords={
'time': np.arange(5),
'x': np.arange(10),
'y': np.arange(10),
'r': np.arange(10),
}
)
slider = pn.widgets.DiscreteSlider(name='Time', options=list(dst.time.data))
im = dst.image.interactive.isel(time=slider).hvplot.image(
colorbar=True,
data_aspect=1
).opts(framewise=False)
li = dst.profile.interactive.isel(time=slider).hvplot.line(
x='r'
)
row = pn.Row(im.panel(), li.panel())
app = pn.Column(im.widgets(), row)
app.show()
When an image has sliders, moving the sliders when zoomed in resets the zoom to the initial view.
This does not happen with this piece of code using Holoviews directly, i.e. the zoom is not changed when zoomed in and the slider is moved.