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
921 stars 123 forks source link

Grid bounds and scaling #335

Closed parkero closed 2 years ago

parkero commented 2 years ago

Hello and thanks for the great library. I have run into the following problem and I was wondering if I could get some insight.

How to describe the following grid in k3d?

I am attempting to create a grid with the following bounds

xmin, xmax = (-3, 3) # x domain
ymin, ymax = (-3, 3) # y domain
zmin, zmax = (0, 1) # probability of occurrence

Visualized as a cube(oid) very similar to: (ignore surfaces)

I have tried the following (minimized) code sample without success:

import k3d
import numpy as np

xmin, xmax, xres = (-3, 3, 25)
ymin, ymax, yres = (-3, 3, 25)

plot = k3d.plot(grid=[xmin, ymin, 0, xmax, ymax, 1], grid_auto_fit=False)
plot.display()

which produces: k3dbounds which is -1 to 2 on Z instead of 0 to 1 as expected

Any advice?

artur-trzesiok commented 2 years ago

K3D have internal prcedure "ensureTwoTicksOnGrids": https://github.com/K3D-tools/K3D-jupyter/blob/main/js/src/providers/threejs/initializers/Scene.js#L61

At this point we cannot control it - it is always enabled.

artur-trzesiok commented 2 years ago

Main problem is that without 2 ticks we will lost a information about scale: image

We have consistent ticks for every axis.

artur-trzesiok commented 2 years ago

Prototype of solution: image

artur-trzesiok commented 2 years ago

Please download new version of k3d@2.13.0:

It should be there :)

parkero commented 2 years ago

@artur-trzesiok Thant's great! And thank you again for the library.