@@ -74,17 +74,17 @@ This example illustartes the hair color, eye color, and sex of a sample of 8 peo
74
74
75
75
``` python
76
76
import plotly.graph_objects as go
77
- parcats = go.Parcats(
77
+
78
+ fig = go.Figure(go.Parcats(
78
79
dimensions = [
79
80
{' label' : ' Hair' ,
80
81
' values' : [' Black' , ' Black' , ' Black' , ' Brown' , ' Brown' , ' Brown' , ' Red' , ' Brown' ]},
81
82
{' label' : ' Eye' ,
82
83
' values' : [' Brown' , ' Brown' , ' Brown' , ' Brown' , ' Brown' , ' Blue' , ' Blue' , ' Blue' ]},
83
84
{' label' : ' Sex' ,
84
85
' values' : [' Female' , ' Female' , ' Female' , ' Male' , ' Female' , ' Male' , ' Male' , ' Male' ]}]
85
- )
86
+ ))
86
87
87
- fig = go.Figure(parcats)
88
88
fig.show()
89
89
```
90
90
@@ -223,67 +223,39 @@ import numpy as np
223
223
cars_df = pd.read_csv(' https://raw.githubusercontent.com/plotly/datasets/master/imports-85.csv' )
224
224
225
225
# Build parcats dimensions
226
- categorical_dimensions = [
227
- ' body-style' ,
228
- ' drive-wheels' ,
229
- ' fuel-type'
230
- ];
226
+ categorical_dimensions = [' body-style' , ' drive-wheels' , ' fuel-type' ]
231
227
232
- dimensions = [
233
- dict (values = cars_df[label], label = label)
234
- for label in categorical_dimensions
235
- ]
228
+ dimensions = [dict (values = cars_df[label], label = label) for label in categorical_dimensions]
236
229
237
230
# Build colorscale
238
231
color = np.zeros(len (cars_df), dtype = ' uint8' )
239
232
colorscale = [[0 , ' gray' ], [0.33 , ' gray' ],
240
233
[0.33 , ' firebrick' ], [0.66 , ' firebrick' ],
241
- [0.66 , ' blue' ], [1.0 , ' blue' ]];
234
+ [0.66 , ' blue' ], [1.0 , ' blue' ]]
242
235
cmin = - 0.5
243
236
cmax = 2.5
244
237
245
238
# Build figure as FigureWidget
246
239
fig = go.FigureWidget(
247
- data = [
248
- go.Scatter(
249
- x = cars_df.horsepower,
250
- y = cars_df[' highway-mpg' ],
251
- marker = {' color' : color,
252
- ' cmin' : cmin,
253
- ' cmax' : cmax,
254
- ' colorscale' : colorscale,
255
- ' showscale' : True ,
256
- ' colorbar' : {' tickvals' : [0 , 1 , 2 ],
257
- ' ticktext' : [' None' , ' Red' , ' Blue' ]}
258
- },
259
- mode = ' markers' ),
260
-
261
- go.Parcats(
262
- domain = {' y' : [0 , 0.4 ]},
263
- dimensions = dimensions,
264
- line = {
265
- ' colorscale' : colorscale,
266
- ' cmin' : cmin,
267
- ' cmax' : cmax,
268
- ' color' : color,
269
- ' shape' : ' hspline' })
270
- ],
271
- layout = go.Layout(
272
- height = 800 ,
273
- xaxis = {' title' : ' Horsepower' },
274
- yaxis = {' title' : ' MPG' ,
275
- ' domain' : [0.6 , 1 ]},
276
- dragmode = ' lasso' ,
277
- hovermode = ' closest' )
240
+ data = [go.Scatter(x = cars_df.horsepower, y = cars_df[' highway-mpg' ],
241
+ marker = {' color' : color, ' cmin' : cmin, ' cmax' : cmax,
242
+ ' colorscale' : colorscale, ' showscale' : True ,
243
+ ' colorbar' : {' tickvals' : [0 , 1 , 2 ], ' ticktext' : [' None' , ' Red' , ' Blue' ]}},
244
+ mode = ' markers' ),
245
+
246
+ go.Parcats(domain = {' y' : [0 , 0.4 ]}, dimensions = dimensions,
247
+ line = {' colorscale' : colorscale, ' cmin' : cmin,
248
+ ' cmax' : cmax, ' color' : color, ' shape' : ' hspline' })]
278
249
)
279
250
251
+ fig.update_layout(height = 800 , xaxis = {' title' : ' Horsepower' },
252
+ yaxis = {' title' : ' MPG' , ' domain' : [0.6 , 1 ]},
253
+ dragmode = ' lasso' , hovermode = ' closest' )
254
+
280
255
# Build color selection widget
281
256
color_toggle = widgets.ToggleButtons(
282
257
options = [' None' , ' Red' , ' Blue' ],
283
- index = 1 ,
284
- description = ' Brush Color:' ,
285
- disabled = False ,
286
- )
258
+ index = 1 , description = ' Brush Color:' , disabled = False )
287
259
288
260
# Update color callback
289
261
def update_color (trace , points , state ):
0 commit comments