Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 213602d

Browse filesBrowse files
chriddypjonmmease
authored andcommitted
A few updates to the migration guide (plotly#1048)
1 parent dbe8adb commit 213602d
Copy full SHA for 213602d

File tree

Expand file treeCollapse file tree

1 file changed

+52
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+52
-4
lines changed

‎migration-guide.md

Copy file name to clipboardExpand all lines: migration-guide.md
+52-4Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Migration to Version 3
2-
There are many new and great features in Plotly 3.0 including deeper Jupyter integration, deeper figure validation, improved performance, and more. This guide contains the a summary of the breaking changes that you need to be aware of when migrating code from version 2 to version 3.
2+
There are many new and great features in Plotly 3.0 including deeper Jupyter integration, deeper figure validation, improved performance, and more. This guide contains the a summary of the breaking changes that you need to be aware of when migrating code from version 2 to version 3.
3+
4+
For a high level overview, read our [announcement post](https://medium.com/@plotlygraphs/introducing-plotly-py-3-0-0-7bb1333f69c6).
35

46
## Simple FigureWidget Example
57
We now have seamless integration with the Jupyter widget ecosystem. We've introduced a new graph object called `go.FigureWidget` that acts like a regular plotly `go.Figure` that can be directly displayed in the notebook.
@@ -10,8 +12,11 @@ import plotly
1012
import plotly.graph_objs as go
1113

1214
f = go.FigureWidget()
15+
f # printing the widget will display it
1316
```
1417

18+
This means that `plotly.offline.iplot` and `plotly.offline.init_notebook_mode()` are no longer required (although still supported).
19+
1520
## Tab Completion
1621
Entering ``f.add_<tab>`` displays add methods for all of the supported trace types. Try it!
1722
```
@@ -29,8 +34,6 @@ f
2934

3035
![Simple Scatter](example_images/simple_scatter.png)
3136

32-
Notice that you don't need to use one of the legacy `iplot` methods to display a `FigureWidget`. Its visual representation is the plot itself!
33-
3437
## New Plotly Object Representation
3538
Plotly figures and graph objects have an updated `__repr__` method that displays objects in a pretty printed form that can be copied, pasted, and evaluated to recreate the object.
3639

@@ -111,11 +114,56 @@ go.Scatter(
111114
)
112115
```
113116

117+
You can still use `dict` as well. The previous figure is equivalent to:
118+
119+
```
120+
import plotly.graph_objs as go
121+
dict(
122+
type='scatter',
123+
x=[0],
124+
y=[0],
125+
marker=go.scatter.Marker(
126+
color='rgb(255,45,15)'
127+
)
128+
)
129+
```
130+
131+
which is also equivalent to
132+
```
133+
import plotly.graph_objs as go
134+
dict(
135+
type='scatter',
136+
x=[0],
137+
y=[0],
138+
marker=dict(
139+
color='rgb(255,45,15)'
140+
)
141+
)
142+
```
143+
114144
### Property Immutability
115145
In order to support the automatic synchronization a `FigureWidget` object and the front-end view in a notebook, it is necessary for the `FigureWidget` to be aware of all changes to its properties. This is accomplished by presenting the individual properties to the user as immutable objects. For example, the `layout.xaxis.range` property may be assigned using a list, but it will be returned as a tuple. Similarly, object arrays (`Figure.data`, `Layout.images`, `Parcoords.dimensions`, etc.) are now represented as tuples of graph objects, not lists.
116146

117147
### Object Array Classes Deprecated
118-
Since graph object arrays are now represented as tuple of graph objects, the following object array classes are deprecated: `go.Data`, `go.Annotations`, and `go.Frames`
148+
Since graph object arrays are now represented as tuple of graph objects, the following object array classes are deprecated: `go.Data`, `go.Annotations`, and `go.Frames`. Instead, just use lists.
149+
150+
That is, previously we used:
151+
```
152+
layout = go.Layout(
153+
annotations=go.Annotations([
154+
go.layout.Annotations(text='annotation')
155+
])
156+
)
157+
```
158+
159+
Now, we should write:
160+
```
161+
layout = go.Layout(
162+
annotations=[
163+
go.layout.Annotations(text='annotation')
164+
]
165+
)
166+
```
119167

120168
### New Figure.data Assignment
121169
There are new restriction on the assignment of traces to the `data` property of a figure. The assigned value must be a list or a tuple of a subset of the traces already present in the figure. Assignment to `data` may be used to reorder and remove existing traces, but it may not currently be used to add new traces. New traces must be added using the `add_trace`, `add_traces`, or `add_*` methods.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.