from IPython.display import HTML # use IPython tools for embedding HTML('
') import plotly plotly.__version__ import matplotlib.pyplot as plt # side-stepping mpl's backend import plotly.plotly as py import plotly.tools as tls from plotly.graph_objs import * %matplotlib inline py.sign_in("IPython.Demo", "1fw3zw2o13") fig1 = plt.figure() import matplotlib.pyplot as plt import numpy as np x = np.linspace(-2.0, 2.0, 10000) # The x-values sigma = np.linspace(0.4, 1.0, 4) # Some different values of sigma # Evaluate a Gaussian for each sigma gaussians = [(2*np.pi*s**2)**-0.5 * np.exp(-0.5*x**2/s**2) for s in sigma] ax = plt.axes() for s,y in zip(sigma, gaussians): ax.plot(x, y, lw=1.25, label=r"$\sigma = %3.2f$"%s) formula = r"$y(x)=\frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{x^2}{2\sigma^2}}$" ax.text(0.05, 0.80, formula, transform=ax.transAxes, fontsize=20) ax.set_xlabel(r"$x$", fontsize=18) ax.set_ylabel(r"$y(x)$", fontsize=18) ax.legend() plt.show() py.iplot_mpl(fig1) # Translate figure to Plotly from plotly.graph_objs import Data, Layout, Figure tls.embed('MattSundquist', '1896') # Convert MPL figure to Plotly my_fig = tls.mpl_to_plotly(fig1) print my_fig.to_string() # check out your graph. help(Data) # check out data # Strip out the data from the Figure my_data = my_fig.get_data() my_data tls.embed('MattSundquist', 1891) # our MATLAB figure with a bit of styling tls.embed('MattSundquist', 1899) from IPython.display import display, HTML import urllib2 display(HTML( urllib2.urlopen('https://raw.githubusercontent.com/plotly/python-user-guide/master/custom.css').read()))