API docs¶
ipyvolume.volume¶
-
ipyvolume.volume.
quickvolshow
(data, lighting=False, data_min=None, data_max=None, tf=None, stereo=False, width=400, height=500, ambient_coefficient=0.5, diffuse_coefficient=0.8, specular_coefficient=0.5, specular_exponent=5, downscale=1, level=[0.1, 0.5, 0.9], opacity=[0.01, 0.05, 0.1], level_width=0.1, **kwargs)[source]¶ Visualize a 3d array using volume rendering
Parameters: - data – 3d numpy array
- lighting – boolean, to use lighting or not, if set to false, lighting parameters will be overriden
- data_min – minimum value to consider for data, if None, computed using np.nanmin
- data_max – maximum value to consider for data, if None, computed using np.nanmax
- tf – transfer function (see ipyvolume.transfer_function, or use the argument below)
- stereo – stereo view for virtual reality (cardboard and similar VR head mount)
- width – width of rendering surface
- height – height of rendering surface
- ambient_coefficient – lighting parameter
- diffuse_coefficient – lighting parameter
- specular_coefficient – lighting parameter
- specular_exponent – lighting parameter
- downscale – downscale the rendering for better performance, for instance when set to 2, a 512x512 canvas will show a 256x256 rendering upscaled, but it will render twice as fast.
- level – level(s) for the where the opacity in the volume peaks, maximum sequence of length 3
- opacity – opacity(ies) for each level, scalar or sequence of max length 3
- level_width – width of the (gaussian) bumps where the opacity peaks, scalar or sequence of max length 3
- kwargs – extra argument passed to Volume and default transfer function
Returns:
ipyvolume.pylab¶
-
ipyvolume.pylab.
scatter
(x, y, z, color='red', size=2, size_selected=2.6, color_selected='white', marker='diamond', selection=None, **kwargs)[source]¶ Create a scatter 3d plot with
Parameters: - x – 1d numpy array with x positions
- y –
- z –
- color – string format, examples for red:’red’, ‘#f00’, ‘#ff0000’ or ‘rgb(1,0,0)
- size – float representing the size of the glyph in percentage of the viewport, where 100 is the full size of the viewport
- size_selected – like size, but for selected glyphs
- color_selected – like color, but for selected glyphs
- marker – name of the marker, options are: ‘arrow’, ‘box’, ‘diamond’, ‘sphere’
- selection – array with indices of x,y,z arrays of the selected markers, which can have a different size and color
- kwargs –
Returns:
-
ipyvolume.pylab.
quiver
(x, y, z, u, v, w, size=20, size_selected=26.0, color='red', color_selected='white', marker='arrow', **kwargs)[source]¶ Create a quiver plot, which is like a scatter plot but with arrows pointing in the direction given by u, v and w
Parameters: - x – {x}
- y –
- z –
- u – {u}
- v –
- w –
- size – {size}
- size_selected – like size, but for selected glyphs
- color – {color}
- color_selected – like color, but for selected glyphs
- marker – (currently only ‘arrow’ would make sense)
- kwargs –
Returns:
-
ipyvolume.pylab.
volshow
(data, lighting=False, data_min=None, data_max=None, tf=None, stereo=False, ambient_coefficient=0.5, diffuse_coefficient=0.8, specular_coefficient=0.5, specular_exponent=5, downscale=1, level=[0.1, 0.5, 0.9], opacity=[0.01, 0.05, 0.1], level_width=0.1, controls=True)[source]¶ Visualize a 3d array using volume rendering.
Currently only 1 volume can be rendered.
Parameters: - data – 3d numpy array
- lighting – boolean, to use lighting or not, if set to false, lighting parameters will be overriden
- data_min – minimum value to consider for data, if None, computed using np.nanmin
- data_max – maximum value to consider for data, if None, computed using np.nanmax
- tf – transfer function (or a default one)
- stereo – stereo view for virtual reality (cardboard and similar VR head mount)
- ambient_coefficient – lighting parameter
- diffuse_coefficient – lighting parameter
- specular_coefficient – lighting parameter
- specular_exponent – lighting parameter
- downscale – downscale the rendering for better performance, for instance when set to 2, a 512x512 canvas will show a 256x256 rendering upscaled, but it will render twice as fast.
- level – level(s) for the where the opacity in the volume peaks, maximum sequence of length 3
- opacity – opacity(ies) for each level, scalar or sequence of max length 3
- level_width – width of the (gaussian) bumps where the opacity peaks, scalar or sequence of max length 3
- controls – add controls for lighting and transfer function or not
Returns:
-
ipyvolume.pylab.
figure
(key=None, width=400, height=500, lighting=True, controls=True, debug=False, **kwargs)[source]¶ Create a new figure (if no key is given) or return the figure associated with key
Parameters: - key – Python object that identifies this figure
- width – pixel width of WebGL canvas
- height –
- lighting – use lighting or not
- controls – show controls or not
- debug – show debug buttons or not
Returns:
-
ipyvolume.pylab.
gcc
()[source]¶ Return the current container, that is the widget holding the figure and all the control widgets, buttons etc.
-
ipyvolume.pylab.
show
(extra_widgets=[])[source]¶ Display (like in IPython.display.dispay(...) the current figure
-
ipyvolume.pylab.
save
(filename, copy_js=True, makedirs=True)[source]¶ Save the figure/visualization as html file, and optionally copy the .js file to the same directory
-
ipyvolume.pylab.
savefig
(filename, timeout_seconds=10)[source]¶ Save the current figure to an image (png or jpeg) to a file
-
ipyvolume.pylab.
transfer_function
(level=[0.1, 0.5, 0.9], opacity=[0.01, 0.05, 0.1], level_width=0.1, controls=True)[source]¶ Create a transfer function, see volshow
-
class
ipyvolume.pylab.
style
[source]¶ ‘Static class that mimics a matplotlib module.
Example: >>> import ipyvolume.pylab as p3 >>> p3.style.use(‘light’]) >>> p3.style.use(‘seaborn-darkgrid’]) >>> p3.style.use([‘seaborn-darkgrid’, {‘axes.x.color’:’orange’}])
- Possible style values:
- figure.facecolor: background color
- axes.color: color of the box around the volume/viewport
- xaxis.color: color of xaxis
- yaxis.color: color of xaxis
- zaxis.color: color of xaxis