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)
| 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) |
no test coverage detected