widgetti / ipyvolume

3d plotting for Python in the Jupyter notebook based on IPython widgets using WebGL
MIT License
1.94k stars 234 forks source link

Zoom variable #94

Open oroszl opened 6 years ago

oroszl commented 6 years ago

Is it possible to set the zoom of a figure programatically ? If not it would be a nice feature if this would be possible.

TimoFriedri commented 6 years ago

Hi,

I'm also puzzled. How do I set the "Zoom level" via python code. I can overwrite the figure.matrix_world variable, but this does not change the figure, where in contrast this works fine with figure.camera_fov.

figure.matrix_world is the variable thats changing as soon as I zoom via mousewheel.

What am I missing?

maartenbreddels commented 6 years ago

On master this is now possible, see https://github.com/maartenbreddels/ipyvolume/blob/f6a444502baa6b457e62ffdecf9696fa6d4021b8/ipyvolume/pylab.py#L926 (the api docs currently don't render on readthedocs).

maartenbreddels commented 6 years ago

https://github.com/maartenbreddels/ipyvolume/commit/aad9183c60cdea32f82aa05f8077beee79f83618 is the commit, from the unittests you can also see the usage.

TimoFriedri commented 6 years ago

Hi,

thanks so far. I have major issues with the newer versions in master.

If I install up to the mentioned commit into my env, ipv.view() has no effect at all. Plots work.

If I install up to newest master, ipv.view() still has no effect + the plots do not show up in a jupyter notebook anymore

d = np.array([1.0,2.0,3.5])
f = ipv.figure(width=600, height=400)
# ipv.scatter(x=d,y=d,z=d)
ipv.view(elevation=45)
ipv.show()

Works and I can see the empty axes.

d = np.array([1.0,2.0,3.5])
f = ipv.figure(width=600, height=400)
ipv.scatter(x=d,y=d,z=d)
ipv.view(elevation=45)
ipv.show()

Does not work. Just white nothing. As I reopen or refresh the notebook, I can see there is an element (broken red symbol or VBox(children=(Figure(camera=PerspectiveCamera(fov=46.0, ... text


Update: I have the exact same issue with jupyterlab. I updated all jupyterlab widgets (0.4.6 was installed for ipyvolume)


0.4.6 from conda-forge works as expected except obviously ipv.view(distance=42) does not work.

maartenbreddels commented 6 years ago

Few things to try:

Also, check the browser console for error msg'es.