I tired to create an interactive plot between two dimensions by using two separated histograms. However, once the link_selections.instance()
was created and added necessary plots, the box_select
didn’t work correctly and there was nothing happened on two charts neither.
The code looks like below
import hvplot.pandas
# and other necessary libraries
pn.extension()
pd.options.plotting.backend = 'holoviews'
df = pd.read_pickle(file_path)
# I plan to make hist chart on 'speed_avg' and 'enginespeed_avg' columns with int32 dtype
# the whole dataset contains over 5 million items
# I just use the first 500 rows as an example
a = df['speed_avg'].loc[:500].hvplot.hist(bins=20).options(width=600, tools=['tap', 'box_select', 'hover'])
b = df['enginespeed_avg'].loc[:500].hvplot.hist(bins=30).options(width=600, xlim=(0, 3000), tools=['tap', 'box_select', 'hover'])
ls = hv.link_selections.instance()
ls(a) + ls(b)
such code above will show two hist charts correctly in my jupyter notebook, but nothing happened when I selected some part of a
neither b
.
I then ran ls.selection_expr
and it returned (dim('enginespeed_avg')>=830.58507391747)&(dim('enginespeed_avg')<=1378.457414343002)
which looked good.
But when I eliminated the jupyer notebook and went back the to the script, it will show an error info below such like: linked_selection aborted because it could not display selection for all elements: One or more dimensions in the expression (dim('enginespeed_avg')>=83058507391747)&(dim('enginespeed_avg')<=1378457414343002) could not resolve on ':Dataset [index] (speed_avg)' Ensure all dimensions referenced by the expression are present on the supplied object on ':Histogram [speed_avg] (speed_avg_count)'.
Notice that it returns a wrong dim range 83058507391747
and 1378457414343002
. Comparing with what we got in expr
order 830.58507391747
and 1378.457414343002
, it just transform a float
data to a huge int
without the point
Not quite sure if others got the same issue, or maybe some other best practice to avoid this case?
Many thanks for your support!