Skip to content

Commit 53e599c

Browse files
selector argument accepting function now correctly documented
For the BaseFigure.select_traces, and its subclasses' select_* and related functions (for_each_*).
1 parent 63f20ee commit 53e599c

File tree

4 files changed

+426
-150
lines changed

4 files changed

+426
-150
lines changed

packages/python/plotly/codegen/figure.py

+33-12
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,16 @@ def select_{plural_name}(
256256
257257
Parameters
258258
----------
259-
selector: dict or None (default None)
259+
selector: dict, function, or None (default None)
260260
Dict to use as selection criteria.
261261
{singular_name} objects will be selected if they contain
262262
properties corresponding to all of the dictionary's keys, with
263263
values that exactly match the supplied values. If None
264-
(the default), all {singular_name} objects are selected.
264+
(the default), all {singular_name} objects are selected. If a
265+
function, it must be a function accepting a single argument and
266+
returning a boolean. The function will be called on each
267+
{singular_name} and those for which the function returned True will
268+
be in the selection.
265269
row, col: int or None (default None)
266270
Subplot row and column index of {singular_name} objects to select.
267271
To select {singular_name} objects by row and column, the Figure
@@ -288,12 +292,16 @@ def for_each_{singular_name}(
288292
----------
289293
fn:
290294
Function that inputs a single {singular_name} object.
291-
selector: dict or None (default None)
295+
selector: dict, function, or None (default None)
292296
Dict to use as selection criteria.
293297
{singular_name} objects will be selected if they contain
294298
properties corresponding to all of the dictionary's keys, with
295299
values that exactly match the supplied values. If None
296-
(the default), all {singular_name} objects are selected.
300+
(the default), all {singular_name} objects are selected. If a
301+
function, it must be a function accepting a single argument and
302+
returning a boolean. The function will be called on each
303+
{singular_name} and those for which the function returned True will
304+
be in the selection.
297305
row, col: int or None (default None)
298306
Subplot row and column index of {singular_name} objects to select.
299307
To select {singular_name} objects by row and column, the Figure
@@ -327,12 +335,16 @@ def update_{plural_name}(
327335
patch: dict
328336
Dictionary of property updates to be applied to all
329337
{singular_name} objects that satisfy the selection criteria.
330-
selector: dict or None (default None)
338+
selector: dict, function, or None (default None)
331339
Dict to use as selection criteria.
332340
{singular_name} objects will be selected if they contain
333341
properties corresponding to all of the dictionary's keys, with
334342
values that exactly match the supplied values. If None
335-
(the default), all {singular_name} objects are selected.
343+
(the default), all {singular_name} objects are selected. If a
344+
function, it must be a function accepting a single argument and
345+
returning a boolean. The function will be called on each
346+
{singular_name} and those for which the function returned True will
347+
be in the selection.
336348
overwrite: bool
337349
If True, overwrite existing properties. If False, apply updates
338350
to existing properties recursively, preserving existing
@@ -383,12 +395,15 @@ def select_{method_prefix}{plural_name}(
383395
384396
Parameters
385397
----------
386-
selector: dict or None (default None)
398+
selector: dict, function, or None (default None)
387399
Dict to use as selection criteria.
388400
Annotations will be selected if they contain properties corresponding
389401
to all of the dictionary's keys, with values that exactly match
390402
the supplied values. If None (the default), all {plural_name} are
391-
selected.
403+
selected. If a function, it must be a function accepting a single
404+
argument and returning a boolean. The function will be called on
405+
each {singular_name} and those for which the function returned True
406+
will be in the selection.
392407
row, col: int or None (default None)
393408
Subplot row and column index of {plural_name} to select.
394409
To select {plural_name} by row and column, the Figure must have been
@@ -428,12 +443,15 @@ def for_each_{method_prefix}{singular_name}(
428443
----------
429444
fn:
430445
Function that inputs a single {singular_name} object.
431-
selector: dict or None (default None)
446+
selector: dict, function, or None (default None)
432447
Dict to use as selection criteria.
433448
Traces will be selected if they contain properties corresponding
434449
to all of the dictionary's keys, with values that exactly match
435450
the supplied values. If None (the default), all {plural_name} are
436-
selected.
451+
selected. If a function, it must be a function accepting a single
452+
argument and returning a boolean. The function will be called on
453+
each {singular_name} and those for which the function returned True
454+
will be in the selection.
437455
row, col: int or None (default None)
438456
Subplot row and column index of {plural_name} to select.
439457
To select {plural_name} by row and column, the Figure must have been
@@ -486,12 +504,15 @@ def update_{method_prefix}{plural_name}(
486504
patch: dict or None (default None)
487505
Dictionary of property updates to be applied to all {plural_name} that
488506
satisfy the selection criteria.
489-
selector: dict or None (default None)
507+
selector: dict, function, or None (default None)
490508
Dict to use as selection criteria.
491509
Traces will be selected if they contain properties corresponding
492510
to all of the dictionary's keys, with values that exactly match
493511
the supplied values. If None (the default), all {plural_name} are
494-
selected.
512+
selected. If a function, it must be a function accepting a single
513+
argument and returning a boolean. The function will be called on
514+
each {singular_name} and those for which the function returned True
515+
will be in the selection.
495516
row, col: int or None (default None)
496517
Subplot row and column index of {plural_name} to select.
497518
To select {plural_name} by row and column, the Figure must have been

packages/python/plotly/plotly/basedatatypes.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,15 @@ def select_traces(self, selector=None, row=None, col=None, secondary_y=None):
857857
858858
Parameters
859859
----------
860-
selector: dict or None (default None)
860+
selector: dict, function, or None (default None)
861861
Dict to use as selection criteria.
862862
Traces will be selected if they contain properties corresponding
863863
to all of the dictionary's keys, with values that exactly match
864864
the supplied values. If None (the default), all traces are
865-
selected.
865+
selected. If a function, it must be a function accepting a single
866+
argument and returning a boolean. The function will be called on
867+
each trace and those for which the function returned True
868+
will be in the selection.
866869
row, col: int or None (default None)
867870
Subplot row and column index of traces to select.
868871
To select traces by row and column, the Figure must have been
@@ -984,12 +987,15 @@ def for_each_trace(self, fn, selector=None, row=None, col=None, secondary_y=None
984987
----------
985988
fn:
986989
Function that inputs a single trace object.
987-
selector: dict or None (default None)
990+
selector: dict, function, or None (default None)
988991
Dict to use as selection criteria.
989992
Traces will be selected if they contain properties corresponding
990993
to all of the dictionary's keys, with values that exactly match
991994
the supplied values. If None (the default), all traces are
992-
selected.
995+
selected. If a function, it must be a function accepting a single
996+
argument and returning a boolean. The function will be called on
997+
each trace and those for which the function returned True
998+
will be in the selection.
993999
row, col: int or None (default None)
9941000
Subplot row and column index of traces to select.
9951001
To select traces by row and column, the Figure must have been
@@ -1038,12 +1044,15 @@ def update_traces(
10381044
patch: dict or None (default None)
10391045
Dictionary of property updates to be applied to all traces that
10401046
satisfy the selection criteria.
1041-
selector: dict or None (default None)
1047+
selector: dict, function, or None (default None)
10421048
Dict to use as selection criteria.
10431049
Traces will be selected if they contain properties corresponding
10441050
to all of the dictionary's keys, with values that exactly match
10451051
the supplied values. If None (the default), all traces are
1046-
selected.
1052+
selected. If a function, it must be a function accepting a single
1053+
argument and returning a boolean. The function will be called on
1054+
each trace and those for which the function returned True
1055+
will be in the selection.
10471056
row, col: int or None (default None)
10481057
Subplot row and column index of traces to select.
10491058
To select traces by row and column, the Figure must have been

0 commit comments

Comments
 (0)