import plotly.plotly as py from plotly.graph_objs import * from plotly.widgets import GraphWidget from IPython.display import display, HTML, Image import numpy as np import math from IPython.html import widgets import colorlover as cl Image(url='http://i.imgur.com/CzMRuMo.gif') z = np.arange(1,20,0.1) x = np.cos(4*z)*( np.power(z+1,3) ) y = np.sin(4*z)*( np.power(z+1,3) ) colors = cl.interp( cl.scales['11']['div']['RdYlBu'], z) HTML( cl.to_html( colors ) ) class shifter: def __init__(self): self.x = np.cos(4*z)*( np.power(z+1,3) ) self.y = np.sin(4*z)*( np.power(z+1,3) ) self.colors = cl.interp( cl.scales['11']['div']['RdYlBu'], z) def on_phase_change(self, name, old_value, new_value): self.x = np.cos(4*z+new_value)*( np.power(z+1,3) ) self.y = np.sin(4*z+new_value)*( np.power(z+1,3) ) self.replot() def replot(self): g.restyle({ 'x': [self.x], 'y': [self.y] }) p_slider = widgets.FloatSliderWidget(min=0,max=10,value=1,step=0.05) p_slider.description = 'Phase shift' p_slider.value = 1 p_state = shifter() p_slider.on_trait_change(p_state.on_phase_change, 'value') g.restyle( { 'x':[x], 'y':[y], 'z':[z], 'marker':{'size':np.power(z,1.2),'opacity':0.9,'color':colors}, 'type':'scatter3d' } ) g = GraphWidget() display(p_slider) display(g) help(Scatter3d) from IPython.core.display import HTML import urllib2 HTML(urllib2.urlopen('http://bit.ly/1Bf5Hft').read())