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

Method update

plotly/basedatatypes.py:862–933  ·  view source on GitHub ↗

Update the properties of the figure with a dict and/or with keyword arguments. This recursively updates the structure of the figure object with the values in the input dict / keyword arguments. Parameters ---------- dict1 : dict

(self, dict1=None, overwrite=False, **kwargs)

Source from the content-addressed store, hash-verified

860 _set_property_provided_value(self, name, arg, provided)
861
862 def update(self, dict1=None, overwrite=False, **kwargs):
863 """
864 Update the properties of the figure with a dict and/or with
865 keyword arguments.
866
867 This recursively updates the structure of the figure
868 object with the values in the input dict / keyword arguments.
869
870 Parameters
871 ----------
872 dict1 : dict
873 Dictionary of properties to be updated
874 overwrite: bool
875 If True, overwrite existing properties. If False, apply updates
876 to existing properties recursively, preserving existing
877 properties that are not specified in the update operation.
878 kwargs :
879 Keyword/value pair of properties to be updated
880
881 Examples
882 --------
883 >>> import plotly.graph_objs as go
884 >>> fig = go.Figure(data=[{'y': [1, 2, 3]}])
885 >>> fig.update(data=[{'y': [4, 5, 6]}]) # doctest: +ELLIPSIS
886 Figure(...)
887 >>> fig.to_plotly_json() # doctest: +SKIP
888 {'data': [{'type': 'scatter',
889 'uid': 'e86a7c7a-346a-11e8-8aa8-a0999b0c017b',
890 'y': array([4, 5, 6], dtype=int32)}],
891 'layout': {}}
892
893 >>> fig = go.Figure(layout={'xaxis':
894 ... {'color': 'green',
895 ... 'range': [0, 1]}})
896 >>> fig.update({'layout': {'xaxis': {'color': 'pink'}}}) # doctest: +ELLIPSIS
897 Figure(...)
898 >>> fig.to_plotly_json() # doctest: +SKIP
899 {'data': [],
900 'layout': {'xaxis':
901 {'color': 'pink',
902 'range': [0, 1]}}}
903
904 Returns
905 -------
906 BaseFigure
907 Updated figure
908 """
909 with self.batch_update():
910 for d in [dict1, kwargs]:
911 if d:
912 for k, v in d.items():
913 update_target = self[k]
914 if update_target == () or overwrite:
915 if k == "data":
916 # Overwrite all traces as special due to
917 # restrictions on trace assignment
918 self.data = ()
919 self.add_traces(v)

Callers 9

dataMethod · 0.45
update_tracesMethod · 0.45
update_layoutMethod · 0.45
_add_annotation_likeMethod · 0.45
layoutMethod · 0.45
_build_dispatch_planMethod · 0.45
_set_compound_propMethod · 0.45
_set_array_propMethod · 0.45

Calls 4

batch_updateMethod · 0.95
add_tracesMethod · 0.95
_perform_updateMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected