K3D-tools / K3D-jupyter

K3D lets you create 3D plots backed by WebGL with high-level API (surfaces, isosurfaces, voxels, mesh, cloud points, vtk objects, volume renderer, colormaps, etc). The primary aim of K3D-jupyter is to be easy for use as stand alone package like matplotlib, but also to allow interoperation with existing libraries as VTK.
MIT License
941 stars 123 forks source link

AttributeError: 'Line' object has no attribute 'display' #368

Closed Tsingularity closed 2 years ago

Tsingularity commented 2 years ago

Description

I installed k3d using conda install -c conda-forge k3d and I can successfully import it in the notebook. However, when I am trying to run the following example in the doc:

import k3d
plot = k3d.line([[0, 0, 0],
                 [1, 1, 1]])
plot.display()

It got the following error for the display function: AttributeError: 'Line' object has no attribute 'display'.

I installed nodejs in my conda env and also enabled nbextention as described in the readme, but the above error still exists.

Could you please take a look at this issue? Huge thanks in advance!

Tsingularity commented 2 years ago

i just found that, after remove .display(), the plot is displayed in the notebook lol. Just wondering any idea why this could happen? image

Tsingularity commented 2 years ago

and looks like other type of plot's display() works for me. So I guess the doc's first plot example is outdated and misleading? image

tgandor commented 2 years ago

Hi, line is an object, which can be displayed on a plot (or multiple plots for that matter). So it's the plot that should be displayed.

Using just a line object as Jupyter cell value causes creating of an implicit Plot, and displaying it below the cell. This is a convenience feature, normally you should create a plot and add objects to it plot += k3d.line(...) etc.

When you're done, you can .display() the plot, when the scene is ready (and not re-render it after every object added).

Tsingularity commented 2 years ago

Thanks for the help!

Just in case someone else encounter the same issue as me, could u please modify the installation doc? Thanks! image