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 this branch including deeper Jupyter integration, deeper figure validation, improved performance, and more. To get started right away with Plotly, check out the [tutorial](#getting-started) below.
2
3
3
-
Plotly 3 introduces huge enhancements to the `plotly.py` visualization library from tab completion for properties in the Jupyter to a tighter validation detection to catch unknown figure errors, plotly 3 provides better workflow for Plotly users.
4
-
4
+
To install and enable with Jupyter, run:
5
+
```
6
+
pip install plotly==3.0.0rc9
7
+
pip install ipywidgets # only necessary for Jupyter Notebook environments
8
+
```
5
9
6
-
# Added
7
-
[asd](#foo)
10
+
In addition, to add JupyterLab support run the following commands:
8
11
12
+
```
13
+
pip install jupyterlab
14
+
jupyter labextension install @jupyter-widgets/jupyterlab-manager # install the Jupyter widgets extension
15
+
jupyter labextension install plotlywidget
16
+
```
9
17
10
-
# What's Added?
18
+
## 3.0.0rc9 [08-06-2018]
19
+
### Added
20
+
- update traces interactively
11
21
- Traces can be added and updated interactively by simply assigning to properties
12
-
13
22
- The full Traces and Layout API is generated from the plotly schema to provide a great experience for interactive use in the notebook
23
+
- Jupyter friendly docstrings
24
+
- Jupyter friendly docstrings on constructor params and properties
25
+
- Support for setting array properties as numpy arrays. When numpy arrays are used, ipywidgets binary serialization protocol is used to avoid converting these to JSON strings.
26
+
- Context manager API for animation
27
+
- Programmatic export of figures to static SVG images (and PNG and PDF with cairosvg installed).
14
28
15
-
- Data validation covering the full API with clear, informative error messages
29
+
### Removed
30
+
- We have removed `.to_string`, `.strip_style`, `.get_data`, `.validate` and `.to_dataframe` methods from `plotly.graph_objs` objects. For example run `dir(plotly.graph_objs.Scatter)` to get all the (magic) methods of the Scatter class.
16
31
17
32
33
+
### Changed
34
+
- Improved data validation covering the full API with clear, informative error messages. This means that incorrect properties and/or values now always raise a `ValueError` with a description of the error, the invalid property, and the avaialble properties on the level that it was placed in the graph object. Eg. `go.Scatter(foo=123)` raises a validation error. See https://plot.ly/python/reference/ for a reference to all valid properties and values in the Python API.
18
35
19
-
-Jupyter friendly docstrings on constructor params and properties
36
+
-graph objects are not `dict`s anymore. Running a cell of a graph object prints out a dict-style representation of the object:
20
37
21
-
- Support for setting array properties as numpy arrays. When numpy arrays are used, ipywidgets binary serialization protocol is used to avoid converting these to JSON strings.
38
+
Eg. `plotly.graph_objs.Scatter()` prints
22
39
23
-
- Context manager API for animation
40
+
```
41
+
Scatter(**{
42
+
'type': 'scatter'
43
+
})
44
+
```
24
45
25
-
- Programmatic export of figures to static SVG images (and PNG and PDF with cairosvg installed).
46
+
- plotly objects now have a `.to_plotly_json` method that converts the object to a dict:
- all graph objects must now be written using their full path. For example if one wants to customize the marker param in a scatter object, write `plotly.graph_objs.scatter.Marker` instead of `plotly.graph_objs.Marker`. If the marker object lives in a `plotly.graph_objs.Scatter()` object then a deprecated message will appear. Similarly
54
+
55
+
```
56
+
import plotly.graph_objs as go
57
+
go.Scatter(
58
+
x=[0],
59
+
y=[0],
60
+
marker=go.Marker(
61
+
color='rgb(255,45,15)'
62
+
)
63
+
)
64
+
```
65
+
66
+
produces a deprecation warning but
67
+
68
+
```
69
+
import plotly.graph_objs as go
70
+
go.Scatter(
71
+
x=[0],
72
+
y=[0],
73
+
marker=go.scatter.Marker(
74
+
color='rgb(255,45,15)'
75
+
)
76
+
)
77
+
```
78
+
79
+
does not.
80
+
81
+
-`go.Data()` is deprecated. Use a list or array `[]` instead.
82
+
83
+
84
+
85
+
# Getting Started
86
+
#### Installation
87
+
To install and enable with Jupyter, run:
88
+
```
89
+
pip install plotly==3.0.0rc9
90
+
pip install ipywidgets # only necessary for Jupyter Notebook environments
91
+
```
92
+
93
+
In addition, to add JupyterLab support run the following commands:
94
+
95
+
```
96
+
pip install jupyterlab
97
+
jupyter labextension install @jupyter-widgets/jupyterlab-manager # install the Jupyter widgets extension
98
+
jupyter labextension install plotlywidget
99
+
```
100
+
101
+
## Overview
102
+
```
103
+
# ipyplotly
104
+
from plotly.graph_objs import FigureWidget
105
+
from plotly.callbacks import Points, InputDeviceState
A FigureWidget behaves almost identically to a Figure but it is also an ipywidget that can be displayed directly in the notebook without calling `iplot`
48
-
49
134
```
50
135
f1 = FigureWidget()
51
136
f1
52
137
```
53
138
54
-
## Tab completion
139
+
####Tab completion
55
140
Entering ``f1.add_<tab>`` displays add methods for all of the supported trace types
141
+
```
142
+
# f1.add_
143
+
```
56
144
57
145
Entering ``f1.add_scatter(<tab>)`` displays the names of all of the top-level properties for the scatter trace type
58
146
59
147
Entering ``f1.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
We have removed the following methods from the `plotly.graph_objs` plotly objects:
123
-
-`.to_string`
124
-
-`.strip_style`
125
-
-`.get_data`
126
-
-`.validate`
127
-
-`.to_dataframe`
227
+
# Reset colors to zeros (unselected)
228
+
scatt1.marker.color = np.zeros(iris_class.size)
229
+
selected = np.zeros(iris_class.size)
230
+
```
128
231
129
-
# What is Depreciated?
232
+
#### Configure brushing callback
233
+
```
234
+
# Assigning these variables here is not required. But doing so tricks Jupyter into
235
+
# providing property tab completion on the parameters to the brush function below
236
+
trace, points, state = scatt1, Points(), InputDeviceState()
130
237
131
-
- Plotly Objects form a tree hierarchy. For instance we have `go.Scatter` and the nested attribute `Marker` lives under scatter at `go.Scatter.Marker`. Now params that live a few nodes down the tree under a plotly class must be referenced in the full path.
238
+
def brush(trace, points, state):
239
+
inds = np.array(points.point_inds)
240
+
if inds.size:
241
+
selected[inds] = 1
242
+
trace.marker.color = selected
132
243
133
-
Example:
134
-
```
135
-
fig = go.Figure(
136
-
data=[
137
-
go.Scatter(
138
-
go.Scatter.Marker(
139
-
symbol=0,
140
-
),
141
-
x=[1,2,3],
142
-
y=[1,2,3],
143
-
)
144
-
]
145
-
)
244
+
scatt1.on_selected(brush)
146
245
```
147
246
148
-
`go.Data` is depreciated:
149
-
150
-
Instead of
247
+
Now box or lasso select points on the figure and see them turn red
151
248
152
249
```
153
-
go.Data([])
250
+
# Reset brush
251
+
selected = np.zeros(iris_class.size)
252
+
scatt1.marker.color = selected
154
253
```
155
254
156
-
drop the go.Data and use a `list` instead:
255
+
#### Create second plot with different features
256
+
```
257
+
f2 = FigureWidget(data=[{'type': 'scatter',
258
+
'x': iris_df.petal_length,
259
+
'y': iris_df.sepal_width,
260
+
'mode': 'markers'}])
261
+
f2
262
+
```
157
263
158
264
```
159
-
[]
265
+
# Set axis titles
266
+
f2.layout.xaxis.title = 'petal_length'
267
+
f2.layout.yaxis.title = 'sepal_width'
268
+
269
+
# Grab trace reference
270
+
scatt2 = f2.data[0]
271
+
272
+
# Set marker styles / colorbars to match between figures
273
+
scatt2.marker = scatt1.marker
274
+
275
+
# Configure brush on both plots to update both plots
0 commit comments