Skip to content

Commit 600f275

Browse files
Merge pull request #2894 from plotly/selector-accept-int-string
Selector accept int string
2 parents 953e85d + 9985b30 commit 600f275

File tree

8 files changed

+366
-181
lines changed

8 files changed

+366
-181
lines changed

Diff for: packages/python/plotly/codegen/figure.py

+20-14
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,18 @@ def __init__(self, data=None, layout=None,
8989
frames=None, skip_invalid=False, **kwargs):
9090
\"\"\"
9191
Create a new :class:{fig_classname} instance
92-
92+
9393
Parameters
9494
----------
9595
data
9696
{data_description}
97-
97+
9898
layout
9999
{layout_description}
100-
100+
101101
frames
102102
{frames_description}
103-
103+
104104
skip_invalid: bool
105105
If True, invalid properties in the figure specification will be
106106
skipped silently. If False (default) invalid properties in the
@@ -233,8 +233,8 @@ def add_{trace_node.plotly_name}(self"""
233233
* If False, only select yaxis objects associated with the primary
234234
y-axis of the subplot.
235235
* If None (the default), do not filter yaxis objects based on
236-
a secondary y-axis condition.
237-
236+
a secondary y-axis condition.
237+
238238
To select yaxis objects by secondary y-axis, the Figure must
239239
have been created using plotly.subplots.make_subplots. See
240240
the docstring for the specs argument to make_subplots for more
@@ -287,7 +287,7 @@ def for_each_{singular_name}(
287287
\"\"\"
288288
Apply a function to all {singular_name} objects that satisfy the
289289
specified selection criteria
290-
290+
291291
Parameters
292292
----------
293293
fn:
@@ -329,7 +329,7 @@ def update_{plural_name}(
329329
\"\"\"
330330
Perform a property update operation on all {singular_name} objects
331331
that satisfy the specified selection criteria
332-
332+
333333
Parameters
334334
----------
335335
patch: dict
@@ -395,15 +395,17 @@ def select_{method_prefix}{plural_name}(
395395
396396
Parameters
397397
----------
398-
selector: dict, function, or None (default None)
398+
selector: dict, function, int, str, or None (default None)
399399
Dict to use as selection criteria.
400400
Annotations will be selected if they contain properties corresponding
401401
to all of the dictionary's keys, with values that exactly match
402402
the supplied values. If None (the default), all {plural_name} are
403403
selected. If a function, it must be a function accepting a single
404404
argument and returning a boolean. The function will be called on
405405
each {singular_name} and those for which the function returned True
406-
will be in the selection.
406+
will be in the selection. If an int N, the Nth {singular_name} matching row
407+
and col will be selected (N can be negative). If a string S, the selector
408+
is equivalent to dict(type=S).
407409
row, col: int or None (default None)
408410
Subplot row and column index of {plural_name} to select.
409411
To select {plural_name} by row and column, the Figure must have been
@@ -443,15 +445,17 @@ def for_each_{method_prefix}{singular_name}(
443445
----------
444446
fn:
445447
Function that inputs a single {singular_name} object.
446-
selector: dict, function, or None (default None)
448+
selector: dict, function, int, str or None (default None)
447449
Dict to use as selection criteria.
448450
Traces will be selected if they contain properties corresponding
449451
to all of the dictionary's keys, with values that exactly match
450452
the supplied values. If None (the default), all {plural_name} are
451453
selected. If a function, it must be a function accepting a single
452454
argument and returning a boolean. The function will be called on
453455
each {singular_name} and those for which the function returned True
454-
will be in the selection.
456+
will be in the selection. If an int N, the Nth {singular_name} matching row
457+
and col will be selected (N can be negative). If a string S, the selector
458+
is equivalent to dict(type=S).
455459
row, col: int or None (default None)
456460
Subplot row and column index of {plural_name} to select.
457461
To select {plural_name} by row and column, the Figure must have been
@@ -504,15 +508,17 @@ def update_{method_prefix}{plural_name}(
504508
patch: dict or None (default None)
505509
Dictionary of property updates to be applied to all {plural_name} that
506510
satisfy the selection criteria.
507-
selector: dict, function, or None (default None)
511+
selector: dict, function, int, str or None (default None)
508512
Dict to use as selection criteria.
509513
Traces will be selected if they contain properties corresponding
510514
to all of the dictionary's keys, with values that exactly match
511515
the supplied values. If None (the default), all {plural_name} are
512516
selected. If a function, it must be a function accepting a single
513517
argument and returning a boolean. The function will be called on
514518
each {singular_name} and those for which the function returned True
515-
will be in the selection.
519+
will be in the selection. If an int N, the Nth {singular_name} matching row
520+
and col will be selected (N can be negative). If a string S, the selector
521+
is equivalent to dict(type=S).
516522
row, col: int or None (default None)
517523
Subplot row and column index of {plural_name} to select.
518524
To select {plural_name} by row and column, the Figure must have been

0 commit comments

Comments
 (0)