#!/usr/bin/env python # coding: utf-8 # # Overview # This notebook will contain a running set of examples of backward compatibility considerations. # In[1]: # Imports from plotly.offline import init_notebook_mode, plot, iplot import plotly.graph_objs as go # Initialize notebook mode (Needed by iplot) init_notebook_mode(connected=True) # In[2]: # The graph_obj constructors (inluding Figure) are now pretty compatible with legacy code fig = go.Figure([go.Scatter(x=[1, 2, 3], y=[3, 1, 6], marker=go.scatter.Marker(color='green'))]) plot(fig, filename='exports/tmp.html') # /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/plotly/graph_objs/_deprecations.py:426: DeprecationWarning: # # plotly.graph_objs.Marker is deprecated. # Please replace it with one of the following more specific types # - plotly.graph_objs.scatter.Marker # - plotly.graph_objs.histogram.selected.Marker # - etc. # # In[4]: iplot(fig) # In[11]: # Instead of using iplot, we can construct a FigureWidget and it will be displayed in the notebook automatically fig_widget = go.FigureWidget([go.Scatter(x=[1, 2, 3], y=[3, 1, 6], marker=go.Marker(color='green'))]) fig_widget # In[12]: # Now we can update x-axis range in-place and see the updates reflected in the already displayed figure above fig_widget.layout.xaxis.range = [0, 5] # In[13]: # Trace properties can be modified in place as well scatt = fig_widget.data[0] scatt.line.dash = 'longdash' # In[14]: # Detailed value validation is performed on parameters passed to the Figure constructor # Here we set 'moded to 'marker' instead of 'markers' go.Figure([go.Scatter(x=[1, 2, 3], y=[3, 1, 6], marker=go.Marker(color='green'), mode='marker')]) # In[15]: # The same validation is performed on property assignment scatt.mode = 'marker' # In[ ]: