-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table adds points to list #2326
Comments
This definitely appears to be a bug.
Another (quite stupid) bug, Streams have a reset method which is what makes
Not as far as I know.
The new PointDraw stream will handle a bunch of the stuff you're doing here and simplify your example a lot, since it adds an explicit tool you have to activate it'll also be more convenient for your legend issue above.
I'd like to turn your example into a demo for the docs so I'll rework it a bit and get back to you. |
That would be great. Don't hurry, it's not that important for me. |
Nice example!
Bokeh allows the legend to be placed outside of the plot, which would be another way to address this issue, but I don't know if HoloViews currently supports that. |
Sure it does, |
Agreed that this would be a great demo! |
Hi, %%opts Points (size=10 color='black')
data = hv.OrderedDict({'x':[], 'y':[]})
points = hv.Points(data).redim.soft_range(x=(-3, 3))
points_s = streams.PointDraw(data=points.columns(), source=points)
x_range = streams.RangeX(source=points, x_range =(-3, 3))
reset = streams.PlotReset(transient=True)
def fit(data, degree, x_range):
if data == None or len(data['x']) < 2:
return hv.Curve(([], []))
else:
x, y = data['x'], data['y']
p = np.poly1d(np.polyfit(x, y, degree))
t = np.linspace(*x_range, 300)
return hv.Curve((t, p(t)))
def plot(data, deg, x_range, resetting):
polys = {'linear': 1, 'quadratic':2, 'cubic':3, 'custom':deg}
return hv.NdOverlay({name: fit(data, degree, x_range) for name, degree in polys.items()})
def plot_table(data):
return hv.Table(data, kdims=['x', 'y'])
dmap = hv.DynamicMap(plot,sort=True, kdims='deg', streams=[points_s, x_range, reset]).redim.range(deg=(1, 20))
((points * dmap ).options(width=700, height=500, legend_position='top') + hv.DynamicMap(plot_table, streams=[points_s])).cols(1) But I still have some questions:
Some other things I noticed when playing around with the point_draw notebook point_draw notebook :
%%opts Points (color='color' size=10)
#[tools=['hover'] ]
data = hv.OrderedDict({'x':[1, 2, 4], 'y':[1, 2 , 4], 'color':['blue', 'red', 'green']})
points = hv.Points(data, vdims='color')
points gives: which goes away if you include the [tools=['hover'] plot option. |
Now that is odd! |
You already seem to have figured out that you have to use the from holoviews.plotting.bokeh.callbacks import ResetCallback
class FixedResetCallback(ResetCallback):
def _process_msg(self, msg):
return {'resetting': True}
hv.streams.Stream._callbacks['bokeh'][hv.streams.PlotReset] = FixedResetCallback But we will have a fix out soon.
That sounds like a bug that we'll have to investigate.
HoloViews does not currently support using the |
I've just double checked this and cannot reproduce, works fine for me both in classic notebook and jupyterlab. |
While I am not able to make your example work, it looks like it is very cool! I'm still new to HoloViews, so not sure what is going wrong (I've simply copy pasted the above code in various constellations). Is it still planned that this example makes it into the gallery soon? |
@philippjfr It would be worth noting the bugs identified in this issue and determining which ones have been resolved and filing new issues for the ones that still need to be addressed. |
As far as I can tell the issues here have been addressed, if any haven't been addressed they should be discussed in a dedicated issue. |
Hi,
I played around a bit and now I have some questions.
(Hoping this is the right place for this.) So I want to have a plot where I can place points which then will be used for polynomial interpolations. This is what I have so far:
So now my questions:
By tapping every point gets added twice to the list points. But If I skip " + hv.Table(...) " in
the return of function "plot" it's like expected. (Every point gets added just once.)
I tried to use the reset button to clear the points list. How can I set reset back to False (in the stream)? transient=True seems not to be correct.
Is there an easy way to prevent placing points when tapping on the legend? (to switch off a curve)
Is there an easy way to drag and drop, remove points?
Sometimes a curve disappears when zooming out.
Sorry for the long list and if this is already answered in the docs. If so, a reference would be enough of course. So feel free to ignore stuff ; ) Improvements are welcome. ; )
Thanks for the great work you're doing.
The text was updated successfully, but these errors were encountered: