Add a trace to the figure Parameters ---------- trace : BaseTraceType or dict Either: - An instances of a trace classe from the plotly.graph_objs package (e.g plotly.graph_objs.Scatter, plotly.graph_objs.Bar)
(
self, trace, row=None, col=None, secondary_y=None, exclude_empty_subplots=False
)
| 266 | return super().for_each_trace(fn, selector, row, col, secondary_y) |
| 267 | |
| 268 | def add_trace( |
| 269 | self, trace, row=None, col=None, secondary_y=None, exclude_empty_subplots=False |
| 270 | ) -> "Figure": |
| 271 | """ |
| 272 | |
| 273 | Add a trace to the figure |
| 274 | |
| 275 | Parameters |
| 276 | ---------- |
| 277 | trace : BaseTraceType or dict |
| 278 | Either: |
| 279 | - An instances of a trace classe from the plotly.graph_objs |
| 280 | package (e.g plotly.graph_objs.Scatter, plotly.graph_objs.Bar) |
| 281 | - or a dicts where: |
| 282 | |
| 283 | - The 'type' property specifies the trace type (e.g. |
| 284 | 'scatter', 'bar', 'area', etc.). If the dict has no 'type' |
| 285 | property then 'scatter' is assumed. |
| 286 | - All remaining properties are passed to the constructor |
| 287 | of the specified trace type. |
| 288 | |
| 289 | row : 'all', int or None (default) |
| 290 | Subplot row index (starting from 1) for the trace to be |
| 291 | added. Only valid if figure was created using |
| 292 | `plotly.tools.make_subplots`. |
| 293 | If 'all', addresses all rows in the specified column(s). |
| 294 | col : 'all', int or None (default) |
| 295 | Subplot col index (starting from 1) for the trace to be |
| 296 | added. Only valid if figure was created using |
| 297 | `plotly.tools.make_subplots`. |
| 298 | If 'all', addresses all columns in the specified row(s). |
| 299 | secondary_y: boolean or None (default None) |
| 300 | If True, associate this trace with the secondary y-axis of the |
| 301 | subplot at the specified row and col. Only valid if all of the |
| 302 | following conditions are satisfied: |
| 303 | * The figure was created using `plotly.subplots.make_subplots`. |
| 304 | * The row and col arguments are not None |
| 305 | * The subplot at the specified row and col has type xy |
| 306 | (which is the default) and secondary_y True. These |
| 307 | properties are specified in the specs argument to |
| 308 | make_subplots. See the make_subplots docstring for more info. |
| 309 | * The trace argument is a 2D cartesian trace |
| 310 | (scatter, bar, etc.) |
| 311 | exclude_empty_subplots: boolean |
| 312 | If True, the trace will not be added to subplots that don't already |
| 313 | have traces. |
| 314 | Returns |
| 315 | ------- |
| 316 | BaseFigure |
| 317 | The Figure that add_trace was called on |
| 318 | |
| 319 | Examples |
| 320 | -------- |
| 321 | |
| 322 | >>> from plotly import subplots |
| 323 | >>> import plotly.graph_objs as go |
| 324 | |
| 325 | Add two Scatter traces to a figure |
no outgoing calls