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

Method select_traces

plotly/basedatatypes.py:1115–1195  ·  view source on GitHub ↗

Select traces from a particular subplot cell and/or traces that satisfy custom selection criteria. Parameters ---------- selector: dict, function, int, str or None (default None) Dict to use as selection criteria. Traces will be selec

(self, selector=None, row=None, col=None, secondary_y=None)

Source from the content-addressed store, hash-verified

1113 trace._trace_ind = trace_ind
1114
1115 def select_traces(self, selector=None, row=None, col=None, secondary_y=None):
1116 """
1117 Select traces from a particular subplot cell and/or traces
1118 that satisfy custom selection criteria.
1119
1120 Parameters
1121 ----------
1122 selector: dict, function, int, str or None (default None)
1123 Dict to use as selection criteria.
1124 Traces will be selected if they contain properties corresponding
1125 to all of the dictionary's keys, with values that exactly match
1126 the supplied values. If None (the default), all traces are
1127 selected. If a function, it must be a function accepting a single
1128 argument and returning a boolean. The function will be called on
1129 each trace and those for which the function returned True
1130 will be in the selection. If an int N, the Nth trace matching row
1131 and col will be selected (N can be negative). If a string S, the selector
1132 is equivalent to dict(type=S).
1133 row, col: int or None (default None)
1134 Subplot row and column index of traces to select.
1135 To select traces by row and column, the Figure must have been
1136 created using plotly.subplots.make_subplots. If None
1137 (the default), all traces are selected.
1138 secondary_y: boolean or None (default None)
1139 * If True, only select traces associated with the secondary
1140 y-axis of the subplot.
1141 * If False, only select traces associated with the primary
1142 y-axis of the subplot.
1143 * If None (the default), do not filter traces based on secondary
1144 y-axis.
1145
1146 To select traces by secondary y-axis, the Figure must have been
1147 created using plotly.subplots.make_subplots. See the docstring
1148 for the specs argument to make_subplots for more info on
1149 creating subplots with secondary y-axes.
1150 Returns
1151 -------
1152 generator
1153 Generator that iterates through all of the traces that satisfy
1154 all of the specified selection criteria
1155 """
1156 if not selector and not isinstance(selector, int):
1157 selector = {}
1158
1159 if row is not None or col is not None or secondary_y is not None:
1160 grid_ref = self._validate_get_grid_ref()
1161 filter_by_subplot = True
1162
1163 if row is None and col is not None:
1164 # All rows for column
1165 grid_subplot_ref_tuples = [ref_row[col - 1] for ref_row in grid_ref]
1166 elif col is None and row is not None:
1167 # All columns for row
1168 grid_subplot_ref_tuples = grid_ref[row - 1]
1169 elif col is not None and row is not None:
1170 # Single grid cell
1171 grid_subplot_ref_tuples = [grid_ref[row - 1][col - 1]]
1172 else:

Callers 6

for_each_traceMethod · 0.95
update_tracesMethod · 0.95
assert_select_tracesMethod · 0.80
assert_orderingsFunction · 0.80

Calls 2

Tested by 4

assert_select_tracesMethod · 0.64
assert_orderingsFunction · 0.64