#!/usr/bin/env python # coding: utf-8 # In[1]: from IPython.core.display import display, HTML import json import numpy as np def plot3D(X, Y, Z, height=600, xlabel = "X", ylabel = "Y", zlabel = "Z", initialCamera = None): options = { "width": "100%", "style": "surface", "showPerspective": True, "showGrid": True, "showShadow": False, "keepAspectRatio": True, "height": str(height) + "px" } if initialCamera: options["cameraPosition"] = initialCamera data = [ {"x": X[y,x], "y": Y[y,x], "z": Z[y,x]} for y in range(X.shape[0]) for x in range(X.shape[1]) ] visCode = r"""
""" htmlCode = "" display(HTML(htmlCode)) # In[2]: X, Y = np.meshgrid(np.linspace(-3,3,50),np.linspace(-3,3,50)) Z = np.sin(X**2 + Y**2)**2/(X**2+Y**2) plot3D(X, Y, Z) # In[ ]: