You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many new and great features in Plotly 3.0 including deeper Jupyter integration, deeper figure validation, improved performance, and more. To get started right away with Plotly, check out the tutorial below:
3
3
4
4
## Simple FigureWidget Example
5
-
We now have a seamless integration of Jupyter support and the Plotly objects. We've introduced a new graph object called `go.FigureWidget` that acts like a regular plotly `go.Figure` that can be displayed in Jupyter.
5
+
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.
6
6
7
7
Simple Example: Make a Scatter Plot
8
-
```
8
+
```python
9
9
import plotly
10
10
import plotly.graph_objs as go
11
11
@@ -22,11 +22,15 @@ Entering `f.add_scatter(<tab>)` displays the names of all of the top-level prope
22
22
23
23
Entering `f.add_scatter(<shift+tab>)` displays the signature pop-up. Expanding this pop-up reveals the method doc string which contains the descriptions of all of the top level properties. Let's finish add a scatter trace to `f`:
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
+
30
34
## New Plotly Object Representation
31
35
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.
32
36
@@ -39,27 +43,12 @@ FigureWidget({
39
43
})
40
44
```
41
45
42
-
## New Figure.data Assignment
43
-
- Assignment to the `Figure.data` property must contain a permutation of a subset of the existing traces. Assignment can be used to reorder and remove traces, but cannot currently add new traces.
44
-
45
-
Suppose a figure, fig, has 3 traces. The following command is valid and it will move the third trace to be the first, the first trace to be the second, and it will remove the second trace.
46
-
47
-
```
48
-
fig.data = [fig.data[2], fig.data[0]]
49
-
```
50
-
51
-
However this is not valid:
52
-
```
53
-
fig.data = [fig.data[0], go.Scatter(y=[2, 3, 1])]
54
-
```
55
-
56
-
It's not valid because it's introducing a new trace during assignment. This trace would need to be added using `add_trace` instead.
57
-
46
+
## New add_trace method that handles subplots
47
+
The legacy `append_trace` method for adding traces to subplots has been deprecated in favor of the new `add_trace`, `add_traces`, and `add_*` methods. Each of these new methods accepts optional row/column information that may be used to add traces to subplots for figures initialized by the `plotly.tools.make_subplots` function.
58
48
59
-
## FigureWidget Subplot Example
60
-
Let's create a subplot then turn it into a FigureWidget to display in the notebook. Note that `append_trace` is now deprecated. Use `add_trace` or `add_traces` instead.
49
+
Let's create a subplot then turn it into a FigureWidget to display in the notebook.
Run the following examples to see what is now deprecated or not valid:
83
82
84
-
- Data array properties may not be specified as scalars:
83
+
### Property Immutability
84
+
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.
85
+
86
+
### New Figure.data Assignment
87
+
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.
88
+
89
+
For example, suppose a figure, `fig`, has 3 traces. The following command is valid and it will move the third trace to be the first, the first trace to be the second, and it will remove the second trace.
90
+
85
91
```
86
-
import plotly.graph_objs as go
87
-
go.Bar(x=1)
92
+
fig.data = [fig.data[2], fig.data[0]]
93
+
```
94
+
95
+
However this is not valid:
96
+
```
97
+
fig.data = [fig.data[0], go.Scatter(y=[2, 3, 1])]
88
98
```
89
99
90
-
- Several undocumented `Figure` methods have been removed. These include: `.to_string`, `.strip_style`, `.get_data`, `.validate` and `.to_dataframe`.
100
+
It's not valid because it's introducing a new trace during assignment. This trace would need to be added using `add_trace` instead.
91
101
92
-
- Object arrays such as `Figure.data` and `Layout.images` are now represented as tuples of graph objects, not lists. Run the following as a sanity check:
102
+
### Data array properties may not be specified as scalars
103
+
For example, the following is now invalid:
104
+
```
105
+
import plotly.graph_objs as go
106
+
go.Bar(x=1)
107
+
```
93
108
109
+
This should be replaced by:
94
110
```
95
-
type(go.Figure().data)
111
+
import plotly.graph_objs as go
112
+
go.Bar(x=[1])
96
113
```
114
+
115
+
### Removal of undocumented methods
116
+
Several undocumented `Figure` methods have been removed. These include: `.to_string`, `.strip_style`, `.get_data`, `.validate` and `.to_dataframe`.
0 commit comments