Skip to content

Support **kwargs in update_traces and update_{subplot} methods #1554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions codegen/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def for_each_{singular_name}(self, fn, selector=None, row=None, col=None):

return self

def update_{plural_name}(self, patch, selector=None, row=None, col=None):
def update_{plural_name}(
self, patch=None, selector=None, row=None, col=None, **kwargs):
\"\"\"
Perform a property update operation on all {singular_name} objects
that satisfy the specified selection criteria
Expand All @@ -239,15 +240,19 @@ def update_{plural_name}(self, patch, selector=None, row=None, col=None):
To select {singular_name} objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all {singular_name} objects are selected.

**kwargs
Additional property updates to apply to each selected
{singular_name} object. If a property is specified in
both patch and in **kwargs then the one in **kwargs
takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
\"\"\"
for obj in self.select_{plural_name}(
selector=selector, row=row, col=col):
obj.update(patch)
obj.update(patch, **kwargs)

return self""")

Expand Down
11 changes: 8 additions & 3 deletions plotly/basedatatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,15 @@ def for_each_trace(self, fn, selector=None, row=None, col=None):

return self

def update_traces(self, patch, selector=None, row=None, col=None):
def update_traces(
self, patch=None, selector=None, row=None, col=None, **kwargs):
"""
Perform a property update operation on all traces that satisfy the
specified selection criteria

Parameters
----------
patch: dict
patch: dict or None (default None)
Dictionary of property updates to be applied to all traces that
satisfy the selection criteria.
selector: dict or None (default None)
Expand All @@ -780,14 +781,18 @@ def update_traces(self, patch, selector=None, row=None, col=None):
To select traces by row and column, the Figure must have been
created using plotly.subplots.make_subplots. If None
(the default), all traces are selected.
**kwargs
Additional property updates to apply to each selected trace. If
a property is specified in both patch and in **kwargs then the
one in **kwargs takes precedence.

Returns
-------
self
Returns the Figure object that the method was called on
"""
for trace in self.select_traces(selector=selector, row=row, col=col):
trace.update(patch)
trace.update(patch, **kwargs)
return self

def _select_layout_subplots_by_prefix(
Expand Down
84 changes: 63 additions & 21 deletions plotly/graph_objs/_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -12366,7 +12366,9 @@ def for_each_geo(self, fn, selector=None, row=None, col=None):

return self

def update_geos(self, patch, selector=None, row=None, col=None):
def update_geos(
self, patch=None, selector=None, row=None, col=None, **kwargs
):
"""
Perform a property update operation on all geo objects
that satisfy the specified selection criteria
Expand All @@ -12387,14 +12389,18 @@ def update_geos(self, patch, selector=None, row=None, col=None):
To select geo objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all geo objects are selected.

**kwargs
Additional property updates to apply to each selected
geo object. If a property is specified in
both patch and in **kwargs then the one in **kwargs
takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
"""
for obj in self.select_geos(selector=selector, row=row, col=col):
obj.update(patch)
obj.update(patch, **kwargs)

return self

Expand Down Expand Up @@ -12462,7 +12468,9 @@ def for_each_mapbox(self, fn, selector=None, row=None, col=None):

return self

def update_mapboxes(self, patch, selector=None, row=None, col=None):
def update_mapboxes(
self, patch=None, selector=None, row=None, col=None, **kwargs
):
"""
Perform a property update operation on all mapbox objects
that satisfy the specified selection criteria
Expand All @@ -12483,14 +12491,18 @@ def update_mapboxes(self, patch, selector=None, row=None, col=None):
To select mapbox objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all mapbox objects are selected.

**kwargs
Additional property updates to apply to each selected
mapbox object. If a property is specified in
both patch and in **kwargs then the one in **kwargs
takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
"""
for obj in self.select_mapboxes(selector=selector, row=row, col=col):
obj.update(patch)
obj.update(patch, **kwargs)

return self

Expand Down Expand Up @@ -12558,7 +12570,9 @@ def for_each_polar(self, fn, selector=None, row=None, col=None):

return self

def update_polars(self, patch, selector=None, row=None, col=None):
def update_polars(
self, patch=None, selector=None, row=None, col=None, **kwargs
):
"""
Perform a property update operation on all polar objects
that satisfy the specified selection criteria
Expand All @@ -12579,14 +12593,18 @@ def update_polars(self, patch, selector=None, row=None, col=None):
To select polar objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all polar objects are selected.

**kwargs
Additional property updates to apply to each selected
polar object. If a property is specified in
both patch and in **kwargs then the one in **kwargs
takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
"""
for obj in self.select_polars(selector=selector, row=row, col=col):
obj.update(patch)
obj.update(patch, **kwargs)

return self

Expand Down Expand Up @@ -12654,7 +12672,9 @@ def for_each_scene(self, fn, selector=None, row=None, col=None):

return self

def update_scenes(self, patch, selector=None, row=None, col=None):
def update_scenes(
self, patch=None, selector=None, row=None, col=None, **kwargs
):
"""
Perform a property update operation on all scene objects
that satisfy the specified selection criteria
Expand All @@ -12675,14 +12695,18 @@ def update_scenes(self, patch, selector=None, row=None, col=None):
To select scene objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all scene objects are selected.

**kwargs
Additional property updates to apply to each selected
scene object. If a property is specified in
both patch and in **kwargs then the one in **kwargs
takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
"""
for obj in self.select_scenes(selector=selector, row=row, col=col):
obj.update(patch)
obj.update(patch, **kwargs)

return self

Expand Down Expand Up @@ -12750,7 +12774,9 @@ def for_each_ternary(self, fn, selector=None, row=None, col=None):

return self

def update_ternaries(self, patch, selector=None, row=None, col=None):
def update_ternaries(
self, patch=None, selector=None, row=None, col=None, **kwargs
):
"""
Perform a property update operation on all ternary objects
that satisfy the specified selection criteria
Expand All @@ -12771,14 +12797,18 @@ def update_ternaries(self, patch, selector=None, row=None, col=None):
To select ternary objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all ternary objects are selected.

**kwargs
Additional property updates to apply to each selected
ternary object. If a property is specified in
both patch and in **kwargs then the one in **kwargs
takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
"""
for obj in self.select_ternaries(selector=selector, row=row, col=col):
obj.update(patch)
obj.update(patch, **kwargs)

return self

Expand Down Expand Up @@ -12846,7 +12876,9 @@ def for_each_xaxis(self, fn, selector=None, row=None, col=None):

return self

def update_xaxes(self, patch, selector=None, row=None, col=None):
def update_xaxes(
self, patch=None, selector=None, row=None, col=None, **kwargs
):
"""
Perform a property update operation on all xaxis objects
that satisfy the specified selection criteria
Expand All @@ -12867,14 +12899,18 @@ def update_xaxes(self, patch, selector=None, row=None, col=None):
To select xaxis objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all xaxis objects are selected.

**kwargs
Additional property updates to apply to each selected
xaxis object. If a property is specified in
both patch and in **kwargs then the one in **kwargs
takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
"""
for obj in self.select_xaxes(selector=selector, row=row, col=col):
obj.update(patch)
obj.update(patch, **kwargs)

return self

Expand Down Expand Up @@ -12942,7 +12978,9 @@ def for_each_yaxis(self, fn, selector=None, row=None, col=None):

return self

def update_yaxes(self, patch, selector=None, row=None, col=None):
def update_yaxes(
self, patch=None, selector=None, row=None, col=None, **kwargs
):
"""
Perform a property update operation on all yaxis objects
that satisfy the specified selection criteria
Expand All @@ -12963,13 +13001,17 @@ def update_yaxes(self, patch, selector=None, row=None, col=None):
To select yaxis objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all yaxis objects are selected.

**kwargs
Additional property updates to apply to each selected
yaxis object. If a property is specified in
both patch and in **kwargs then the one in **kwargs
takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
"""
for obj in self.select_yaxes(selector=selector, row=row, col=col):
obj.update(patch)
obj.update(patch, **kwargs)

return self
Loading