CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Avatar for Testing 18.04.

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

ipyvolume jupyter classical notebook

Project: Testing 18.04
Views: 1279
Kernel: Python 3 (Ubuntu Linux)

IpyVolume on CoCalc

https://ipyvolume.readthedocs.io/en/latest/index.html

  • Python 3 (Ubuntu Linux)

  • Plain Jupyter Notebook Server

  • Internet access necessary (hdz2000, ... datasets)

import ipyvolume
ipyvolume.__version__
'0.5.1'
import ipyvolume as ipv import numpy as np
hdz = ipv.datasets.hdz2000.fetch()
ipv.pylab.volshow(hdz.data)
/usr/local/lib/python3.6/dist-packages/ipyvolume/serialize.py:81: RuntimeWarning: invalid value encountered in true_divide gradient = gradient / np.sqrt(gradient[0]**2 + gradient[1]**2 + gradient[2]**2)
# only x is a sequence of arrays x = np.array([[-1, -0.8], [1, -0.1], [0., 0.5]]) y = np.array([0.0, 0.0]) z = np.array([0.0, 0.0]) ipv.figure() s = ipv.scatter(x, y, z, marker='sphere', size=10) ipv.xyzlim(-1, 1) ipv.animation_control(s) # shows controls for animation controls ipv.show()
# create 2d grids: x, y, and r u = np.linspace(-10, 10, 25) x, y = np.meshgrid(u, u) r = np.sqrt(x**2+y**2) print("x,y and z are of shape", x.shape) # and turn them into 1d x = x.flatten() y = y.flatten() r = r.flatten() print("and flattened of shape", x.shape) # create a sequence of 15 time elements time = np.linspace(0, np.pi*2, 15) z = np.array([(np.cos(r + t) * np.exp(-r/5)) for t in time]) print("z is of shape", z.shape) # draw the scatter plot, and add controls with animate_glyphs ipv.figure() s = ipv.scatter(x, z, y, marker="sphere") ipv.animation_control(s, interval=200) ipv.ylim(-3,3) ipv.show()
x,y and z are of shape (25, 25) and flattened of shape (625,) z is of shape (15, 625)
X = np.arange(-5, 5, 0.25*1) Y = np.arange(-5, 5, 0.25*1) X, Y = np.meshgrid(X, Y) R = np.sqrt(X**2 + Y**2) Z = np.sin(R)
from matplotlib import cm colormap = cm.coolwarm znorm = Z - Z.min() znorm /= znorm.ptp() znorm.min(), znorm.max() color = colormap(znorm)
ipv.figure() mesh = ipv.plot_surface(X, Z, Y, color=color[...,:3]) ipv.show()