import plotly plotly.__version__ import plotly.plotly as py # (New syntax!) tools to communicate with Plotly's server import plotly.tools as tls # (NEW!) useful Python/Plotly tools my_creds = tls.get_credentials_file() # read credentials py.sign_in(my_creds['username'], my_creds['api_key']) # (New syntax!) Plotly sign in import numpy as np def fxy(A, L): """ A is the amplitude of the curve L is the length of a side of the square """ x = np.arange(-L/2., L/2., 0.1, float) y = x[:,np.newaxis] return A*(np.cos(np.pi*x*y))**2*np.exp(-(x**2+y**2)/2.) A = 10 # choose a maximum amplitude L = 4 # choose length of square domain # Get coordinate arrays z = fxy(A,L) # Print shape of z z.shape z.min(), z.max() my_surface = dict(z=z, # z coords, a 2D array type='surface', # N.B. 'surface' plot type ) my_fig = dict(data=[my_surface]) # N.B. value link to 'data' must be a list my_fig # print figure dictionary below py.plot(my_fig, validate=False, filename='test-3d-fxy') py.iplot(my_fig, validate=False, filename='test-3d-fxy') # CSS styling within IPython notebook from IPython.core.display import HTML def css_styling(): styles = open("../../python-user-guide/custom.css", "r").read() return HTML(styles) css_styling()