vedo icon indicating copy to clipboard operation
vedo copied to clipboard

Lines() and Line() don't show correctly in jupyter notebook (k3d)

Open ahinoampollack opened this issue 5 years ago • 4 comments

Hi Marco,

I've been busy now using vtkplotter. Maybe I'll do a pull request to your example notebooks folder when I'm done in a few days.

I've noticed some weird behaviors in jupyter notebook.

  1. The Lines() function doesn't seem to work properly. If you run the following code from your example:
    https://github.com/marcomusy/vtkplotter/blob/master/vtkplotter/examples/advanced/fitspheres2.py in the terminal vs a Jupyter notebook, you get a completely different behavior.
from __future__ import division, print_function
from vtkplotter import *

vp = Plotter()

s = vp.load(datadir+"cow.vtk", alpha=0.3)

pts1, pts2, vals, cols = [], [], [], []

for i in range(0, s.N(), 10):
    p = s.points(i)
    pts = s.closestPoint(p, N=12)  # find the N closest points to p
    sph = fitSphere(pts)           # find the fitting sphere
    if sph is None:
        continue

    value = sph.radius * 10
    color = colorMap(value, "jet", 0, 1)  # map value to a RGB color
    n = versor(p - sph.center)  # unit vector from sphere center to p
    vals.append(value)
    cols.append(color)
    pts1.append(p)
    pts2.append(p + n / 8)

vp += Lines(pts1, pts2, c="black")

vp.show()

Notebook (k3d): image Terminal: image

  1. In Line(), if I would like to color the points, I can do as follows:
scals = well['parameter'].values
LineObject = Line(xyz).pointColors(scals, cmap='jet')

The colors on the line appear in the terminal but not in k3d.

I'm guessing these are k3d issues (or something with the translation process). Do you have any workaround thoughts for these two problems? I could make each line separately via a loop maybe, but I'm not sure how to make the colored lines (perhaps I'll make them into very small dots?).

Thank you for all your help!

Noe

ahinoampollack avatar Apr 30 '20 15:04 ahinoampollack

Hi Noe, I'm currently try to fix a whole bunch of issues related to these behaviors in the k3d translation, in a day or 2 i should be able to make a new release hopefully! Cheers M.

marcomusy avatar Apr 30 '20 15:04 marcomusy

Thanks Marco! I really appreciate it!

ahinoampollack avatar Apr 30 '20 20:04 ahinoampollack

Thank you Marco! Issue number 1 has been fixed! Issue number 2 still seems to be problematic (assigning colors to lines in the k3d view), but this is not a priority for myself at the moment, since I just used many small colored points instead of coloring a line.

Thank you again! Noe

ahinoampollack avatar May 04 '20 05:05 ahinoampollack

Hi, indeed the lines problem turned out to be more problematic and tricky to fix than I thought initially.. I'll investigate with the k3d developers for possible solutions..

marcomusy avatar May 04 '20 10:05 marcomusy