0
# Express Plotting Interface
1
2
High-level plotting functions for rapid visualization creation. Plotly Express provides over 40 chart types with sensible defaults and automatic styling, making it ideal for exploratory data analysis and quick visualization prototyping.
3
4
## Capabilities
5
6
### Basic Charts
7
8
Core chart types for fundamental data visualization needs.
9
10
```python { .api }
11
def scatter(data_frame, x=None, y=None, color=None, size=None, hover_name=None,
12
hover_data=None, custom_data=None, text=None, facet_row=None,
13
facet_col=None, facet_col_wrap=None, facet_row_spacing=None,
14
facet_col_spacing=None, error_x=None, error_x_minus=None,
15
error_y=None, error_y_minus=None, animation_frame=None,
16
animation_group=None, category_orders=None, labels=None,
17
orientation=None, color_discrete_sequence=None,
18
color_discrete_map=None, color_continuous_scale=None,
19
range_color=None, color_continuous_midpoint=None,
20
symbol=None, symbol_sequence=None, symbol_map=None,
21
opacity=None, size_max=None, marginal_x=None, marginal_y=None,
22
trendline=None, trendline_options=None, trendline_color_override=None,
23
trendline_scope=None, log_x=False, log_y=False, range_x=None,
24
range_y=None, render_mode='auto', title=None, template=None,
25
width=None, height=None):
26
"""
27
Create a scatter plot.
28
29
Parameters:
30
- data_frame: DataFrame, data to plot
31
- x: str or int or Series, column for x-axis
32
- y: str or int or Series, column for y-axis
33
- color: str or int or Series, column for color encoding
34
- size: str or int or Series, column for size encoding
35
- hover_name: str or int or Series, column for hover tooltip names
36
- hover_data: list of str, columns to show in hover tooltip
37
- text: str or int or Series, column for text annotations
38
- facet_row: str or int or Series, column for subplot rows
39
- facet_col: str or int or Series, column for subplot columns
40
- animation_frame: str or int or Series, column for animation frames
41
- trendline: str, trendline type ('ols', 'lowess', etc.)
42
- log_x: bool, use log scale for x-axis
43
- log_y: bool, use log scale for y-axis
44
- title: str, figure title
45
46
Returns:
47
Figure: Plotly figure object
48
"""
49
50
def line(data_frame, x=None, y=None, line_group=None, color=None,
51
line_dash=None, hover_name=None, hover_data=None, custom_data=None,
52
text=None, facet_row=None, facet_col=None, facet_col_wrap=None,
53
facet_row_spacing=None, facet_col_spacing=None, error_x=None,
54
error_x_minus=None, error_y=None, error_y_minus=None,
55
animation_frame=None, animation_group=None, category_orders=None,
56
labels=None, orientation=None, color_discrete_sequence=None,
57
color_discrete_map=None, line_dash_sequence=None, line_dash_map=None,
58
log_x=False, log_y=False, range_x=None, range_y=None,
59
line_shape=None, render_mode='auto', title=None, template=None,
60
width=None, height=None):
61
"""
62
Create a line chart.
63
64
Parameters:
65
- data_frame: DataFrame, data to plot
66
- x: str, column for x-axis
67
- y: str, column for y-axis
68
- line_group: str, column to group lines by
69
- color: str, column for color encoding
70
- line_dash: str, column for line dash pattern encoding
71
- line_shape: str, line interpolation ('linear', 'spline', 'hv', 'vh', 'hvh', 'vhv')
72
73
Returns:
74
Figure: Plotly figure object
75
"""
76
77
def bar(data_frame, x=None, y=None, color=None, pattern_shape=None,
78
facet_row=None, facet_col=None, facet_col_wrap=None,
79
facet_row_spacing=None, facet_col_spacing=None, hover_name=None,
80
hover_data=None, custom_data=None, text=None, base=None,
81
error_x=None, error_x_minus=None, error_y=None, error_y_minus=None,
82
animation_frame=None, animation_group=None, category_orders=None,
83
labels=None, color_discrete_sequence=None, color_discrete_map=None,
84
color_continuous_scale=None, pattern_shape_sequence=None,
85
pattern_shape_map=None, range_color=None, color_continuous_midpoint=None,
86
opacity=None, orientation=None, barmode='relative', log_x=False,
87
log_y=False, range_x=None, range_y=None, title=None, template=None,
88
width=None, height=None):
89
"""
90
Create a bar chart.
91
92
Parameters:
93
- data_frame: DataFrame, data to plot
94
- x: str, column for x-axis (categories)
95
- y: str, column for y-axis (values)
96
- color: str, column for color encoding
97
- orientation: str, bar orientation ('v' for vertical, 'h' for horizontal)
98
- barmode: str, bar grouping mode ('group', 'overlay', 'relative')
99
- text: str, column for bar text annotations
100
101
Returns:
102
Figure: Plotly figure object
103
"""
104
105
def histogram(data_frame, x=None, y=None, color=None, pattern_shape=None,
106
facet_row=None, facet_col=None, facet_col_wrap=None,
107
facet_row_spacing=None, facet_col_spacing=None, hover_name=None,
108
hover_data=None, animation_frame=None, animation_group=None,
109
category_orders=None, labels=None, color_discrete_sequence=None,
110
color_discrete_map=None, pattern_shape_sequence=None,
111
pattern_shape_map=None, marginal=None, opacity=None,
112
orientation=None, barmode='relative', barnorm=None,
113
histnorm=None, log_x=False, log_y=False, range_x=None,
114
range_y=None, histfunc=None, cumulative=None, nbins=None,
115
text_auto=False, title=None, template=None, width=None, height=None):
116
"""
117
Create a histogram.
118
119
Parameters:
120
- data_frame: DataFrame, data to plot
121
- x: str, column for histogram data
122
- y: str, alternative column for histogram data
123
- color: str, column for color encoding
124
- nbins: int, number of bins
125
- histnorm: str, normalization mode ('', 'percent', 'probability', 'density', 'probability density')
126
- cumulative: bool, whether to show cumulative histogram
127
128
Returns:
129
Figure: Plotly figure object
130
"""
131
132
def box(data_frame, x=None, y=None, color=None, facet_row=None, facet_col=None,
133
facet_col_wrap=None, facet_row_spacing=None, facet_col_spacing=None,
134
hover_name=None, hover_data=None, custom_data=None, animation_frame=None,
135
animation_group=None, category_orders=None, labels=None,
136
color_discrete_sequence=None, color_discrete_map=None, orientation=None,
137
boxmode='group', log_x=False, log_y=False, range_x=None, range_y=None,
138
points=None, notched=None, title=None, template=None, width=None, height=None):
139
"""
140
Create a box plot.
141
142
Parameters:
143
- data_frame: DataFrame, data to plot
144
- x: str, column for categories
145
- y: str, column for continuous values
146
- color: str, column for color encoding
147
- points: str, point display mode ('outliers', 'suspectedoutliers', 'all', False)
148
- notched: bool, whether to show notched boxes
149
150
Returns:
151
Figure: Plotly figure object
152
"""
153
```
154
155
### Geographic Charts
156
157
Visualization functions for geospatial data with support for coordinate mapping and choropleth regions.
158
159
```python { .api }
160
def scatter_geo(data_frame, lat=None, lon=None, locations=None, locationmode=None,
161
geojson=None, featureidkey=None, color=None, text=None,
162
facet_row=None, facet_col=None, facet_col_wrap=None,
163
facet_row_spacing=None, facet_col_spacing=None, hover_name=None,
164
hover_data=None, custom_data=None, size=None, animation_frame=None,
165
animation_group=None, category_orders=None, labels=None,
166
color_discrete_sequence=None, color_discrete_map=None,
167
color_continuous_scale=None, range_color=None,
168
color_continuous_midpoint=None, opacity=None, size_max=None,
169
projection=None, scope=None, center=None, title=None,
170
template=None, width=None, height=None):
171
"""
172
Create a geographic scatter plot.
173
174
Parameters:
175
- data_frame: DataFrame, data to plot
176
- lat: str, column for latitude coordinates
177
- lon: str, column for longitude coordinates
178
- locations: str, column for location identifiers
179
- color: str, column for color encoding
180
- size: str, column for marker size encoding
181
- projection: str, map projection type
182
- scope: str, geographic scope ('world', 'usa', 'europe', etc.)
183
184
Returns:
185
Figure: Plotly figure object
186
"""
187
188
def choropleth(data_frame, geojson=None, featureidkey=None, locations=None,
189
color=None, facet_row=None, facet_col=None, facet_col_wrap=None,
190
facet_row_spacing=None, facet_col_spacing=None, hover_name=None,
191
hover_data=None, custom_data=None, animation_frame=None,
192
animation_group=None, category_orders=None, labels=None,
193
color_discrete_sequence=None, color_discrete_map=None,
194
color_continuous_scale=None, range_color=None,
195
color_continuous_midpoint=None, locationmode=None, scope=None,
196
projection=None, center=None, title=None, template=None,
197
width=None, height=None):
198
"""
199
Create a choropleth map.
200
201
Parameters:
202
- data_frame: DataFrame, data to plot
203
- locations: str, column for region identifiers
204
- color: str, column for color encoding
205
- geojson: dict, GeoJSON data for custom regions
206
- locationmode: str, location matching mode ('ISO-3', 'USA-states', etc.)
207
- scope: str, geographic scope
208
209
Returns:
210
Figure: Plotly figure object
211
"""
212
213
def scatter_map(data_frame, lat=None, lon=None, locations=None, locationmode=None,
214
color=None, text=None, hover_name=None, hover_data=None,
215
custom_data=None, size=None, animation_frame=None,
216
animation_group=None, category_orders=None, labels=None,
217
color_discrete_sequence=None, color_discrete_map=None,
218
color_continuous_scale=None, range_color=None,
219
color_continuous_midpoint=None, opacity=None, size_max=None,
220
projection=None, scope=None, center=None, title=None,
221
template=None, width=None, height=None):
222
"""
223
Create a scatter plot on geographic map.
224
225
Parameters:
226
- data_frame: DataFrame, data to plot
227
- lat: str, column for latitude coordinates
228
- lon: str, column for longitude coordinates
229
- locations: str, column for location identifiers
230
- color: str, column for color encoding
231
- size: str, column for marker size encoding
232
- projection: str, map projection type
233
- scope: str, geographic scope ('world', 'usa', 'europe', etc.)
234
235
Returns:
236
Figure: Plotly figure object
237
"""
238
239
def line_map(data_frame, lat=None, lon=None, locations=None, locationmode=None,
240
color=None, text=None, hover_name=None, hover_data=None,
241
custom_data=None, line_group=None, animation_frame=None,
242
animation_group=None, category_orders=None, labels=None,
243
color_discrete_sequence=None, color_discrete_map=None,
244
projection=None, scope=None, center=None, title=None,
245
template=None, width=None, height=None):
246
"""
247
Create line traces on geographic map.
248
249
Parameters:
250
- data_frame: DataFrame, data to plot
251
- lat: str, column for latitude coordinates
252
- lon: str, column for longitude coordinates
253
- color: str, column for color encoding
254
- line_group: str, column to group lines by
255
- projection: str, map projection type
256
257
Returns:
258
Figure: Plotly figure object
259
"""
260
261
def line_geo(data_frame, lat=None, lon=None, locations=None, locationmode=None,
262
geojson=None, featureidkey=None, color=None, line_dash=None,
263
text=None, facet_row=None, facet_col=None, facet_col_wrap=None,
264
facet_row_spacing=None, facet_col_spacing=None, hover_name=None,
265
hover_data=None, custom_data=None, line_group=None,
266
animation_frame=None, animation_group=None, category_orders=None,
267
labels=None, color_discrete_sequence=None, color_discrete_map=None,
268
line_dash_sequence=None, line_dash_map=None, projection=None,
269
scope=None, center=None, title=None, template=None,
270
width=None, height=None):
271
"""
272
Create geographic line plot with advanced styling.
273
274
Parameters:
275
- data_frame: DataFrame, data to plot
276
- lat: str, column for latitude coordinates
277
- lon: str, column for longitude coordinates
278
- locations: str, column for location identifiers
279
- color: str, column for color encoding
280
- line_group: str, column to group lines by
281
- line_dash: str, column for line dash pattern encoding
282
283
Returns:
284
Figure: Plotly figure object
285
"""
286
287
def choropleth_map(data_frame, geojson=None, featureidkey=None, locations=None,
288
color=None, facet_row=None, facet_col=None, facet_col_wrap=None,
289
facet_row_spacing=None, facet_col_spacing=None, hover_name=None,
290
hover_data=None, custom_data=None, animation_frame=None,
291
animation_group=None, category_orders=None, labels=None,
292
color_discrete_sequence=None, color_discrete_map=None,
293
color_continuous_scale=None, range_color=None,
294
color_continuous_midpoint=None, locationmode=None, scope=None,
295
projection=None, center=None, title=None, template=None,
296
width=None, height=None):
297
"""
298
Create choropleth map with geographic projections.
299
300
Parameters:
301
- data_frame: DataFrame, data to plot
302
- locations: str, column for region identifiers
303
- color: str, column for color encoding
304
- geojson: dict, GeoJSON data for custom regions
305
- locationmode: str, location matching mode
306
- projection: str, map projection type
307
308
Returns:
309
Figure: Plotly figure object
310
"""
311
312
def density_map(data_frame, lat=None, lon=None, z=None, radius=None,
313
hover_name=None, hover_data=None, custom_data=None,
314
animation_frame=None, animation_group=None, labels=None,
315
color_continuous_scale=None, range_color=None,
316
color_continuous_midpoint=None, opacity=None,
317
projection=None, scope=None, center=None, title=None,
318
template=None, width=None, height=None):
319
"""
320
Create density heatmap on geographic map.
321
322
Parameters:
323
- data_frame: DataFrame, data to plot
324
- lat: str, column for latitude coordinates
325
- lon: str, column for longitude coordinates
326
- z: str, column for density values
327
- radius: float, radius for density calculation
328
- projection: str, map projection type
329
330
Returns:
331
Figure: Plotly figure object
332
"""
333
```
334
335
### 3D Visualization
336
337
Three-dimensional plotting capabilities for spatial data visualization.
338
339
```python { .api }
340
def scatter_3d(data_frame, x=None, y=None, z=None, color=None, symbol=None,
341
size=None, text=None, hover_name=None, hover_data=None,
342
custom_data=None, error_x=None, error_x_minus=None, error_y=None,
343
error_y_minus=None, error_z=None, error_z_minus=None,
344
animation_frame=None, animation_group=None, category_orders=None,
345
labels=None, size_max=None, color_discrete_sequence=None,
346
color_discrete_map=None, color_continuous_scale=None,
347
range_color=None, color_continuous_midpoint=None, symbol_sequence=None,
348
symbol_map=None, opacity=None, log_x=False, log_y=False, log_z=False,
349
range_x=None, range_y=None, range_z=None, title=None, template=None,
350
width=None, height=None):
351
"""
352
Create a 3D scatter plot.
353
354
Parameters:
355
- data_frame: DataFrame, data to plot
356
- x: str, column for x-axis
357
- y: str, column for y-axis
358
- z: str, column for z-axis
359
- color: str, column for color encoding
360
- size: str, column for marker size encoding
361
- symbol: str, column for symbol encoding
362
363
Returns:
364
Figure: Plotly figure object
365
"""
366
367
def line_3d(data_frame, x=None, y=None, z=None, color=None, line_dash=None,
368
text=None, line_group=None, hover_name=None, hover_data=None,
369
custom_data=None, error_x=None, error_x_minus=None, error_y=None,
370
error_y_minus=None, error_z=None, error_z_minus=None,
371
animation_frame=None, animation_group=None, category_orders=None,
372
labels=None, color_discrete_sequence=None, color_discrete_map=None,
373
line_dash_sequence=None, line_dash_map=None, log_x=False,
374
log_y=False, log_z=False, range_x=None, range_y=None, range_z=None,
375
title=None, template=None, width=None, height=None):
376
"""
377
Create a 3D line plot.
378
379
Parameters:
380
- data_frame: DataFrame, data to plot
381
- x: str, column for x-axis
382
- y: str, column for y-axis
383
- z: str, column for z-axis
384
- color: str, column for color encoding
385
- line_group: str, column to group lines by
386
387
Returns:
388
Figure: Plotly figure object
389
"""
390
```
391
392
### Statistical Charts
393
394
Specialized functions for statistical data visualization and distribution analysis.
395
396
```python { .api }
397
def violin(data_frame, x=None, y=None, color=None, facet_row=None, facet_col=None,
398
facet_col_wrap=None, facet_row_spacing=None, facet_col_spacing=None,
399
hover_name=None, hover_data=None, custom_data=None, animation_frame=None,
400
animation_group=None, category_orders=None, labels=None,
401
color_discrete_sequence=None, color_discrete_map=None, orientation=None,
402
violinmode='group', log_x=False, log_y=False, range_x=None,
403
range_y=None, points=None, box=None, title=None, template=None,
404
width=None, height=None):
405
"""
406
Create a violin plot.
407
408
Parameters:
409
- data_frame: DataFrame, data to plot
410
- x: str, column for categories
411
- y: str, column for continuous values
412
- color: str, column for color encoding
413
- points: str, point display mode ('outliers', 'suspectedoutliers', 'all', False)
414
- box: bool, whether to show box plot inside violin
415
416
Returns:
417
Figure: Plotly figure object
418
"""
419
420
def strip(data_frame, x=None, y=None, color=None, facet_row=None, facet_col=None,
421
facet_col_wrap=None, facet_row_spacing=None, facet_col_spacing=None,
422
hover_name=None, hover_data=None, custom_data=None, animation_frame=None,
423
animation_group=None, category_orders=None, labels=None,
424
color_discrete_sequence=None, color_discrete_map=None, orientation=None,
425
stripmode='group', log_x=False, log_y=False, range_x=None, range_y=None,
426
title=None, template=None, width=None, height=None):
427
"""
428
Create a strip chart (1D scatter plot).
429
430
Parameters:
431
- data_frame: DataFrame, data to plot
432
- x: str, column for categories
433
- y: str, column for continuous values
434
- color: str, column for color encoding
435
- stripmode: str, point grouping mode ('group', 'overlay')
436
437
Returns:
438
Figure: Plotly figure object
439
"""
440
441
def density_heatmap(data_frame, x=None, y=None, z=None, facet_row=None,
442
facet_col=None, facet_col_wrap=None, facet_row_spacing=None,
443
facet_col_spacing=None, hover_name=None, hover_data=None,
444
animation_frame=None, animation_group=None, category_orders=None,
445
labels=None, orientation=None, color_continuous_scale=None,
446
range_color=None, color_continuous_midpoint=None, marginal_x=None,
447
marginal_y=None, opacity=None, log_x=False, log_y=False,
448
range_x=None, range_y=None, histfunc=None, histnorm=None,
449
nbinsx=None, nbinsy=None, text_auto=False, title=None,
450
template=None, width=None, height=None):
451
"""
452
Create a 2D histogram heatmap.
453
454
Parameters:
455
- data_frame: DataFrame, data to plot
456
- x: str, column for x-axis
457
- y: str, column for y-axis
458
- z: str, optional column for aggregation values
459
- nbinsx: int, number of bins on x-axis
460
- nbinsy: int, number of bins on y-axis
461
- histfunc: str, aggregation function ('count', 'sum', 'avg', 'min', 'max')
462
463
Returns:
464
Figure: Plotly figure object
465
"""
466
```
467
468
### Specialized Charts
469
470
Unique chart types for specific visualization needs and hierarchical data.
471
472
```python { .api }
473
def pie(data_frame, names=None, values=None, color=None, facet_row=None,
474
facet_col=None, facet_col_wrap=None, facet_row_spacing=None,
475
facet_col_spacing=None, color_discrete_sequence=None,
476
color_discrete_map=None, hover_name=None, hover_data=None,
477
custom_data=None, labels=None, title=None, template=None,
478
width=None, height=None):
479
"""
480
Create a pie chart.
481
482
Parameters:
483
- data_frame: DataFrame, data to plot
484
- names: str, column for pie slice labels
485
- values: str, column for pie slice values
486
- color: str, column for color encoding
487
488
Returns:
489
Figure: Plotly figure object
490
"""
491
492
def sunburst(data_frame, names=None, values=None, parents=None, ids=None,
493
path=None, color=None, color_continuous_scale=None,
494
range_color=None, color_continuous_midpoint=None,
495
color_discrete_sequence=None, color_discrete_map=None,
496
hover_name=None, hover_data=None, custom_data=None,
497
labels=None, title=None, template=None, width=None, height=None,
498
branchvalues=None, maxdepth=None):
499
"""
500
Create a sunburst chart for hierarchical data.
501
502
Parameters:
503
- data_frame: DataFrame, data to plot
504
- names: str, column for node names
505
- values: str, column for node values
506
- parents: str, column for parent node names
507
- path: list of str, columns defining hierarchy path
508
- ids: str, column for unique node identifiers
509
510
Returns:
511
Figure: Plotly figure object
512
"""
513
514
def treemap(data_frame, names=None, values=None, parents=None, ids=None,
515
path=None, color=None, color_continuous_scale=None,
516
range_color=None, color_continuous_midpoint=None,
517
color_discrete_sequence=None, color_discrete_map=None,
518
hover_name=None, hover_data=None, custom_data=None,
519
labels=None, title=None, template=None, width=None, height=None,
520
branchvalues=None, maxdepth=None):
521
"""
522
Create a treemap chart for hierarchical data.
523
524
Parameters:
525
- data_frame: DataFrame, data to plot
526
- names: str, column for rectangle names
527
- values: str, column for rectangle sizes
528
- parents: str, column for parent names
529
- path: list of str, columns defining hierarchy path
530
531
Returns:
532
Figure: Plotly figure object
533
"""
534
535
def icicle(data_frame, names=None, values=None, parents=None, ids=None,
536
path=None, color=None, color_continuous_scale=None,
537
range_color=None, color_continuous_midpoint=None,
538
color_discrete_sequence=None, color_discrete_map=None,
539
hover_name=None, hover_data=None, custom_data=None,
540
labels=None, title=None, template=None, width=None, height=None,
541
branchvalues=None, maxdepth=None):
542
"""
543
Create an icicle chart for hierarchical data.
544
545
Parameters:
546
- data_frame: DataFrame, data to plot
547
- names: str, column for node names
548
- values: str, column for node values
549
- parents: str, column for parent node names
550
- path: list of str, columns defining hierarchy path
551
- ids: str, column for unique node identifiers
552
553
Returns:
554
Figure: Plotly figure object
555
"""
556
557
def funnel_area(data_frame, names=None, values=None, color=None,
558
color_discrete_sequence=None, color_discrete_map=None,
559
hover_name=None, hover_data=None, custom_data=None,
560
labels=None, title=None, template=None, width=None, height=None):
561
"""
562
Create a funnel area chart.
563
564
Parameters:
565
- data_frame: DataFrame, data to plot
566
- names: str, column for funnel stage names
567
- values: str, column for funnel stage values
568
- color: str, column for color encoding
569
570
Returns:
571
Figure: Plotly figure object
572
"""
573
```
574
575
### Additional Chart Types
576
577
Extended chart types for specialized visualization needs.
578
579
```python { .api }
580
def area(data_frame, x=None, y=None, line_group=None, color=None,
581
pattern_shape=None, facet_row=None, facet_col=None,
582
facet_col_wrap=None, facet_row_spacing=None, facet_col_spacing=None,
583
hover_name=None, hover_data=None, custom_data=None, text=None,
584
animation_frame=None, animation_group=None, category_orders=None,
585
labels=None, color_discrete_sequence=None, color_discrete_map=None,
586
pattern_shape_sequence=None, pattern_shape_map=None,
587
line_shape=None, groupnorm=None, log_x=False, log_y=False,
588
range_x=None, range_y=None, title=None, template=None,
589
width=None, height=None):
590
"""
591
Create an area chart.
592
593
Parameters:
594
- data_frame: DataFrame, data to plot
595
- x: str, column for x-axis
596
- y: str, column for y-axis
597
- line_group: str, column to group areas by
598
- color: str, column for color encoding
599
- groupnorm: str, normalization mode ('fraction', 'percent')
600
601
Returns:
602
Figure: Plotly figure object
603
"""
604
605
def timeline(data_frame, x_start=None, x_end=None, y=None, color=None,
606
pattern_shape=None, facet_row=None, facet_col=None,
607
facet_col_wrap=None, facet_row_spacing=None, facet_col_spacing=None,
608
hover_name=None, hover_data=None, custom_data=None, text=None,
609
animation_frame=None, animation_group=None, category_orders=None,
610
labels=None, color_discrete_sequence=None, color_discrete_map=None,
611
pattern_shape_sequence=None, pattern_shape_map=None,
612
opacity=None, range_x=None, range_y=None, title=None,
613
template=None, width=None, height=None):
614
"""
615
Create a timeline (Gantt) chart.
616
617
Parameters:
618
- data_frame: DataFrame, data to plot
619
- x_start: str, column for start times
620
- x_end: str, column for end times
621
- y: str, column for task names/categories
622
- color: str, column for color encoding
623
624
Returns:
625
Figure: Plotly figure object
626
"""
627
628
def ecdf(data_frame, x=None, y=None, color=None, text=None, line_dash=None,
629
symbol=None, facet_row=None, facet_col=None, facet_col_wrap=None,
630
facet_row_spacing=None, facet_col_spacing=None, hover_name=None,
631
hover_data=None, animation_frame=None, animation_group=None,
632
category_orders=None, labels=None, orientation=None,
633
color_discrete_sequence=None, color_discrete_map=None,
634
line_dash_sequence=None, line_dash_map=None, symbol_sequence=None,
635
symbol_map=None, margainal_x=None, marginal_y=None,
636
log_x=False, log_y=False, range_x=None, range_y=None,
637
title=None, template=None, width=None, height=None):
638
"""
639
Create an empirical cumulative distribution function (ECDF) plot.
640
641
Parameters:
642
- data_frame: DataFrame, data to plot
643
- x: str, column for continuous data
644
- y: str, alternative column for continuous data
645
- color: str, column for color encoding
646
- orientation: str, plot orientation ('v' or 'h')
647
648
Returns:
649
Figure: Plotly figure object
650
"""
651
652
def imshow(img, zmin=None, zmax=None, origin=None, labels=None, x=None, y=None,
653
animation_frame=None, facet_col=None, facet_col_wrap=None,
654
facet_col_spacing=None, facet_row_spacing=None, color_continuous_scale=None,
655
color_continuous_midpoint=None, range_color=None, title=None,
656
template=None, width=None, height=None, aspect=None,
657
contrast_rescaling=None, binary_string=None, binary_backend='auto',
658
binary_compression_level=None, binary_format='png', text_auto=False):
659
"""
660
Display an image using heatmap-style visualization.
661
662
Parameters:
663
- img: array-like, image data (2D or 3D array)
664
- zmin: float, minimum value for color scale
665
- zmax: float, maximum value for color scale
666
- origin: str, image origin ('lower' or 'upper')
667
- labels: dict, axis labels
668
- x: array-like, x-axis values
669
- y: array-like, y-axis values
670
671
Returns:
672
Figure: Plotly figure object
673
"""
674
```
675
676
### Mapbox Visualizations
677
678
Interactive map visualizations using Mapbox for geographic data with satellite imagery and street map backgrounds.
679
680
```python { .api }
681
def scatter_mapbox(data_frame, lat=None, lon=None, color=None, text=None,
682
hover_name=None, hover_data=None, custom_data=None, size=None,
683
animation_frame=None, animation_group=None, category_orders=None,
684
labels=None, color_discrete_sequence=None, color_discrete_map=None,
685
color_continuous_scale=None, range_color=None,
686
color_continuous_midpoint=None, opacity=None, size_max=None,
687
zoom=None, center=None, mapbox_style=None, title=None,
688
template=None, width=None, height=None):
689
"""
690
Create a scatter plot on a Mapbox map.
691
692
Parameters:
693
- data_frame: DataFrame, data to plot
694
- lat: str, column for latitude coordinates
695
- lon: str, column for longitude coordinates
696
- color: str, column for color encoding
697
- size: str, column for marker size encoding
698
- mapbox_style: str, map style ('open-street-map', 'satellite', etc.)
699
- zoom: float, initial zoom level
700
- center: dict, map center coordinates {'lat': float, 'lon': float}
701
702
Returns:
703
Figure: Plotly figure object
704
"""
705
706
def line_mapbox(data_frame, lat=None, lon=None, color=None, text=None,
707
hover_name=None, hover_data=None, custom_data=None,
708
line_group=None, animation_frame=None, animation_group=None,
709
category_orders=None, labels=None, color_discrete_sequence=None,
710
color_discrete_map=None, zoom=None, center=None,
711
mapbox_style=None, title=None, template=None, width=None, height=None):
712
"""
713
Create line traces on a Mapbox map.
714
715
Parameters:
716
- data_frame: DataFrame, data to plot
717
- lat: str, column for latitude coordinates
718
- lon: str, column for longitude coordinates
719
- color: str, column for color encoding
720
- line_group: str, column to group lines by
721
- mapbox_style: str, map style
722
723
Returns:
724
Figure: Plotly figure object
725
"""
726
727
def choropleth_mapbox(data_frame, geojson=None, featureidkey=None, locations=None,
728
color=None, hover_name=None, hover_data=None, custom_data=None,
729
animation_frame=None, animation_group=None, category_orders=None,
730
labels=None, color_discrete_sequence=None, color_discrete_map=None,
731
color_continuous_scale=None, range_color=None,
732
color_continuous_midpoint=None, opacity=None, zoom=None,
733
center=None, mapbox_style=None, title=None, template=None,
734
width=None, height=None):
735
"""
736
Create a choropleth map on Mapbox.
737
738
Parameters:
739
- data_frame: DataFrame, data to plot
740
- geojson: dict, GeoJSON data for regions
741
- locations: str, column for location identifiers
742
- color: str, column for color encoding
743
- featureidkey: str, GeoJSON property for matching locations
744
745
Returns:
746
Figure: Plotly figure object
747
"""
748
749
def density_mapbox(data_frame, lat=None, lon=None, z=None, radius=None,
750
hover_name=None, hover_data=None, custom_data=None,
751
animation_frame=None, animation_group=None, labels=None,
752
color_continuous_scale=None, range_color=None,
753
color_continuous_midpoint=None, opacity=None,
754
zoom=None, center=None, mapbox_style=None, title=None,
755
template=None, width=None, height=None):
756
"""
757
Create a density heatmap on Mapbox.
758
759
Parameters:
760
- data_frame: DataFrame, data to plot
761
- lat: str, column for latitude coordinates
762
- lon: str, column for longitude coordinates
763
- z: str, column for density values
764
- radius: float, radius for density calculation
765
766
Returns:
767
Figure: Plotly figure object
768
"""
769
```
770
771
### Polar and Ternary Charts
772
773
Specialized coordinate system visualizations for polar and ternary data.
774
775
```python { .api }
776
def scatter_polar(data_frame, r=None, theta=None, color=None, symbol=None,
777
size=None, hover_name=None, hover_data=None, custom_data=None,
778
text=None, animation_frame=None, animation_group=None,
779
category_orders=None, labels=None, color_discrete_sequence=None,
780
color_discrete_map=None, color_continuous_scale=None,
781
range_color=None, color_continuous_midpoint=None,
782
symbol_sequence=None, symbol_map=None, opacity=None,
783
direction='clockwise', start_angle=90, size_max=None,
784
range_r=None, range_theta=None, log_r=False,
785
title=None, template=None, width=None, height=None):
786
"""
787
Create a scatter plot in polar coordinates.
788
789
Parameters:
790
- data_frame: DataFrame, data to plot
791
- r: str, column for radial coordinates
792
- theta: str, column for angular coordinates
793
- color: str, column for color encoding
794
- size: str, column for marker size encoding
795
- direction: str, angular direction ('clockwise' or 'counterclockwise')
796
- start_angle: float, starting angle in degrees
797
798
Returns:
799
Figure: Plotly figure object
800
"""
801
802
def line_polar(data_frame, r=None, theta=None, color=None, line_dash=None,
803
hover_name=None, hover_data=None, custom_data=None, text=None,
804
line_group=None, animation_frame=None, animation_group=None,
805
category_orders=None, labels=None, color_discrete_sequence=None,
806
color_discrete_map=None, line_dash_sequence=None,
807
line_dash_map=None, direction='clockwise', start_angle=90,
808
line_close=False, line_shape=None, range_r=None,
809
range_theta=None, log_r=False, title=None, template=None,
810
width=None, height=None):
811
"""
812
Create line traces in polar coordinates.
813
814
Parameters:
815
- data_frame: DataFrame, data to plot
816
- r: str, column for radial coordinates
817
- theta: str, column for angular coordinates
818
- color: str, column for color encoding
819
- line_close: bool, whether to close the line
820
821
Returns:
822
Figure: Plotly figure object
823
"""
824
825
def bar_polar(data_frame, r=None, theta=None, color=None, hover_name=None,
826
hover_data=None, custom_data=None, base=None, animation_frame=None,
827
animation_group=None, category_orders=None, labels=None,
828
color_discrete_sequence=None, color_discrete_map=None,
829
color_continuous_scale=None, range_color=None,
830
color_continuous_midpoint=None, barnorm=None, barmode='relative',
831
direction='clockwise', start_angle=90, range_r=None,
832
range_theta=None, log_r=False, title=None, template=None,
833
width=None, height=None):
834
"""
835
Create bar traces in polar coordinates.
836
837
Parameters:
838
- data_frame: DataFrame, data to plot
839
- r: str, column for radial values
840
- theta: str, column for angular categories
841
- color: str, column for color encoding
842
- barmode: str, bar grouping mode
843
844
Returns:
845
Figure: Plotly figure object
846
"""
847
848
def scatter_ternary(data_frame, a=None, b=None, c=None, color=None, symbol=None,
849
size=None, text=None, hover_name=None, hover_data=None,
850
custom_data=None, animation_frame=None, animation_group=None,
851
category_orders=None, labels=None, color_discrete_sequence=None,
852
color_discrete_map=None, color_continuous_scale=None,
853
range_color=None, color_continuous_midpoint=None,
854
symbol_sequence=None, symbol_map=None, opacity=None,
855
size_max=None, title=None, template=None, width=None, height=None):
856
"""
857
Create a scatter plot in ternary coordinates.
858
859
Parameters:
860
- data_frame: DataFrame, data to plot
861
- a: str, column for first ternary coordinate
862
- b: str, column for second ternary coordinate
863
- c: str, column for third ternary coordinate
864
- color: str, column for color encoding
865
- size: str, column for marker size encoding
866
867
Returns:
868
Figure: Plotly figure object
869
"""
870
871
def line_ternary(data_frame, a=None, b=None, c=None, color=None, line_dash=None,
872
hover_name=None, hover_data=None, custom_data=None, text=None,
873
line_group=None, animation_frame=None, animation_group=None,
874
category_orders=None, labels=None, color_discrete_sequence=None,
875
color_discrete_map=None, line_dash_sequence=None,
876
line_dash_map=None, line_shape=None, title=None,
877
template=None, width=None, height=None):
878
"""
879
Create line traces in ternary coordinates.
880
881
Parameters:
882
- data_frame: DataFrame, data to plot
883
- a: str, column for first ternary coordinate
884
- b: str, column for second ternary coordinate
885
- c: str, column for third ternary coordinate
886
- color: str, column for color encoding
887
- line_group: str, column to group lines by
888
889
Returns:
890
Figure: Plotly figure object
891
"""
892
```
893
894
### Matrix and Parallel Coordinate Charts
895
896
Specialized visualizations for high-dimensional data analysis and correlation exploration.
897
898
```python { .api }
899
def scatter_matrix(data_frame, dimensions=None, color=None, symbol=None,
900
size=None, hover_name=None, hover_data=None, custom_data=None,
901
category_orders=None, labels=None, color_discrete_sequence=None,
902
color_discrete_map=None, color_continuous_scale=None,
903
range_color=None, color_continuous_midpoint=None,
904
symbol_sequence=None, symbol_map=None, opacity=None,
905
size_max=None, title=None, template=None, width=None, height=None):
906
"""
907
Create a scatter plot matrix for exploring relationships between multiple variables.
908
909
Parameters:
910
- data_frame: DataFrame, data to plot
911
- dimensions: list of str, columns to include in the matrix
912
- color: str, column for color encoding
913
- size: str, column for marker size encoding
914
- symbol: str, column for symbol encoding
915
916
Returns:
917
Figure: Plotly figure object
918
"""
919
920
def parallel_coordinates(data_frame, dimensions=None, color=None,
921
labels=None, color_continuous_scale=None,
922
range_color=None, color_continuous_midpoint=None,
923
title=None, template=None, width=None, height=None):
924
"""
925
Create a parallel coordinates plot for multivariate data visualization.
926
927
Parameters:
928
- data_frame: DataFrame, data to plot
929
- dimensions: list of str, columns to include as parallel axes
930
- color: str, column for color encoding lines
931
- color_continuous_scale: str or list, color scale for continuous data
932
933
Returns:
934
Figure: Plotly figure object
935
"""
936
937
def parallel_categories(data_frame, dimensions=None, color=None,
938
color_continuous_scale=None, labels=None,
939
dimensions_max_cardinality=50, title=None,
940
template=None, width=None, height=None):
941
"""
942
Create a parallel categories (parallel sets) plot for categorical data.
943
944
Parameters:
945
- data_frame: DataFrame, data to plot
946
- dimensions: list of str, categorical columns to include
947
- color: str, column for color encoding
948
- dimensions_max_cardinality: int, maximum number of unique values per dimension
949
950
Returns:
951
Figure: Plotly figure object
952
"""
953
954
def density_contour(data_frame, x=None, y=None, z=None, color=None,
955
facet_row=None, facet_col=None, facet_col_wrap=None,
956
facet_row_spacing=None, facet_col_spacing=None,
957
hover_name=None, hover_data=None, animation_frame=None,
958
animation_group=None, category_orders=None, labels=None,
959
orientation=None, color_discrete_sequence=None,
960
color_discrete_map=None, marginal_x=None, marginal_y=None,
961
trendline=None, trendline_options=None,
962
trendline_color_override=None, trendline_scope=None,
963
log_x=False, log_y=False, range_x=None, range_y=None,
964
histfunc=None, histnorm=None, nbinsx=None, nbinsy=None,
965
title=None, template=None, width=None, height=None):
966
"""
967
Create a 2D density contour plot.
968
969
Parameters:
970
- data_frame: DataFrame, data to plot
971
- x: str, column for x-axis
972
- y: str, column for y-axis
973
- z: str, optional column for contour values
974
- nbinsx: int, number of bins on x-axis
975
- nbinsy: int, number of bins on y-axis
976
- histfunc: str, aggregation function for z values
977
978
Returns:
979
Figure: Plotly figure object
980
"""
981
```
982
983
## Usage Examples
984
985
```python
986
import plotly.express as px
987
import pandas as pd
988
989
# Basic scatter plot with color encoding
990
df = px.data.iris()
991
fig = px.scatter(df, x="sepal_width", y="sepal_length",
992
color="species", title="Iris Dataset")
993
fig.show()
994
995
# Geographic visualization
996
df_geo = px.data.gapminder().query("year==2007")
997
fig = px.choropleth(df_geo, locations="iso_alpha",
998
color="lifeExp", hover_name="country",
999
color_continuous_scale=px.colors.sequential.Plasma)
1000
fig.show()
1001
1002
# 3D scatter plot with multiple encodings
1003
df_3d = px.data.tips()
1004
fig = px.scatter_3d(df_3d, x="total_bill", y="tip", z="size",
1005
color="day", symbol="time")
1006
fig.show()
1007
1008
# Animated scatter plot
1009
df_anim = px.data.gapminder()
1010
fig = px.scatter(df_anim, x="gdpPercap", y="lifeExp",
1011
animation_frame="year", animation_group="country",
1012
size="pop", color="continent", hover_name="country",
1013
log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90])
1014
fig.show()
1015
```