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

Method plotly_update

plotly/basedatatypes.py:2877–2949  ·  view source on GitHub ↗

Perform a Plotly update operation on the figure. Note: This operation both mutates and returns the figure Parameters ---------- restyle_data : dict Traces update specification. See the docstring for the `plotly_restyle` method for de

(
        self, restyle_data=None, relayout_data=None, trace_indexes=None, **kwargs
    )

Source from the content-addressed store, hash-verified

2875 # Update
2876 # ------
2877 def plotly_update(
2878 self, restyle_data=None, relayout_data=None, trace_indexes=None, **kwargs
2879 ):
2880 """
2881 Perform a Plotly update operation on the figure.
2882
2883 Note: This operation both mutates and returns the figure
2884
2885 Parameters
2886 ----------
2887 restyle_data : dict
2888 Traces update specification. See the docstring for the
2889 `plotly_restyle` method for details
2890 relayout_data : dict
2891 Layout update specification. See the docstring for the
2892 `plotly_relayout` method for details
2893 trace_indexes :
2894 Trace index, or list of trace indexes, that the update operation
2895 applies to. Defaults to all trace indexes.
2896
2897 Returns
2898 -------
2899 BaseFigure
2900 None
2901 """
2902
2903 # Handle source_view_id
2904 # ---------------------
2905 # If not None, the source_view_id is the UID of the frontend
2906 # Plotly.js view that initially triggered this update operation
2907 # (e.g. the user clicked a button that triggered an update
2908 # operation). We pass this UID along so that the frontend views can
2909 # determine whether they need to apply the update operation on
2910 # themselves.
2911 if "source_view_id" in kwargs:
2912 msg_kwargs = {"source_view_id": kwargs["source_view_id"]}
2913 else:
2914 msg_kwargs = {}
2915
2916 # Perform update operation
2917 # ------------------------
2918 # This updates the _data and _layout dicts, and returns the changes
2919 # to the traces (restyle_changes) and layout (relayout_changes)
2920 (
2921 restyle_changes,
2922 relayout_changes,
2923 trace_indexes,
2924 ) = self._perform_plotly_update(
2925 restyle_data=restyle_data,
2926 relayout_data=relayout_data,
2927 trace_indexes=trace_indexes,
2928 )
2929
2930 # Send update message
2931 # -------------------
2932 # Send a plotly_update message to the frontend (if any)
2933 if restyle_changes or relayout_changes:
2934 self._send_update_msg(