MCPcopy Index your code
hub / github.com/plotly/plotly.py / add_trace

Method add_trace

plotly/basedatatypes.py:2024–2129  ·  view source on GitHub ↗

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
    )

Source from the content-addressed store, hash-verified

2022 BaseFigure._raise_invalid_rows_cols(name=name, n=n, invalid=vals)
2023
2024 def add_trace(
2025 self, trace, row=None, col=None, secondary_y=None, exclude_empty_subplots=False
2026 ):
2027 """
2028 Add a trace to the figure
2029
2030 Parameters
2031 ----------
2032 trace : BaseTraceType or dict
2033 Either:
2034 - An instances of a trace classe from the plotly.graph_objs
2035 package (e.g plotly.graph_objs.Scatter, plotly.graph_objs.Bar)
2036 - or a dicts where:
2037
2038 - The 'type' property specifies the trace type (e.g.
2039 'scatter', 'bar', 'area', etc.). If the dict has no 'type'
2040 property then 'scatter' is assumed.
2041 - All remaining properties are passed to the constructor
2042 of the specified trace type.
2043
2044 row : 'all', int or None (default)
2045 Subplot row index (starting from 1) for the trace to be
2046 added. Only valid if figure was created using
2047 `plotly.tools.make_subplots`.
2048 If 'all', addresses all rows in the specified column(s).
2049 col : 'all', int or None (default)
2050 Subplot col index (starting from 1) for the trace to be
2051 added. Only valid if figure was created using
2052 `plotly.tools.make_subplots`.
2053 If 'all', addresses all columns in the specified row(s).
2054 secondary_y: boolean or None (default None)
2055 If True, associate this trace with the secondary y-axis of the
2056 subplot at the specified row and col. Only valid if all of the
2057 following conditions are satisfied:
2058 * The figure was created using `plotly.subplots.make_subplots`.
2059 * The row and col arguments are not None
2060 * The subplot at the specified row and col has type xy
2061 (which is the default) and secondary_y True. These
2062 properties are specified in the specs argument to
2063 make_subplots. See the make_subplots docstring for more info.
2064 * The trace argument is a 2D cartesian trace
2065 (scatter, bar, etc.)
2066 exclude_empty_subplots: boolean
2067 If True, the trace will not be added to subplots that don't already
2068 have traces.
2069 Returns
2070 -------
2071 BaseFigure
2072 The Figure that add_trace was called on
2073
2074 Examples
2075 --------
2076
2077 >>> from plotly import subplots
2078 >>> import plotly.graph_objs as go
2079
2080 Add two Scatter traces to a figure
2081

Calls 3

add_tracesMethod · 0.95