mpl_interactions.interactive_scatter

interactive_scatter(x, y, s=None, c=None, cmap=None, vmin=None, vmax=None, alpha=None, edgecolors=None, label=None, xlim='stretch', ylim='stretch', ax=None, slider_format_string=None, title=None, figsize=None, display=True, force_ipywidgets=False, play_buttons=False, play_button_pos='right', **kwargs)[source]

Control a scatter plot using widgets.

Parameters
  • x (function or array-like) – Must be broadcastable with y and any plotting kwargs. Can be a mix of numbers and functions. Any functions in x must return a 1D array or list of the same length as the paired y function or array

  • y (function or array-like) – see x

  • c (array-like or list of colors or color, broadcastable) – Must be broadcastable to x,y and any other plotting kwargs. valid input to plt.scatter, or an array of valid inputs, or a function or an array-like of functions of the same length as f

  • s (float or array-like or function, broadcastable) – valid input to plt.scatter, or an array of valid inputs, or a function or an array-like of functions of the same length as f

  • alpha (float, None, or function(s), broadcastable) – Affects all scatter points. This will compound with any alpha introduced by the c argument

  • edgecolors (colorlike, broadcastable) – passed through to scatter.

  • label (string(s) broadcastable) – labels for the functions being plotted.

  • xlim (string or tuple of floats, optional) – If a tuple it will be passed to ax.set_xlim. Other options are: ‘auto’: rescale the x axis for every redraw ‘stretch’: only ever expand the xlims.

  • ylim (string or tuple of floats, optional) – If a tuple it will be passed to ax.set_ylim. Other options are same as xlim

  • ax (matplotlib axis, optional) – If None a new figure and axis will be created

  • slider_format_string (None, string, or dict) – If None a default value of decimal points will be used. For ipywidgets this uses the new f-string formatting For matplotlib widgets you need to use % style formatting. A string will be used as the default format for all values. A dictionary will allow assigning different formats to different sliders. note: For matplotlib >= 3.3 a value of None for slider_format_string will use the matplotlib ScalarFormatter object for matplotlib slider values.

  • title (None or string) – If a string then you can have it update automatically using string formatting of the names of the parameters. i.e. to include the current value of tau: title=’the value of tau is: {tau:.2f}’

  • figsize (tuple or scalar) – If tuple it will be used as the matplotlib figsize. If a number then it will be used to scale the current rcParams figsize

  • display (boolean) – If True then the output and controls will be automatically displayed

  • force_ipywidgets (boolean) – If True ipywidgets will always be used, even if not using the ipympl backend. If False the function will try to detect if it is ok to use ipywidgets If ipywidgets are not used the function will fall back on matplotlib widgets

  • play_buttons (bool or dict or list(str), optional) – Whether to attach an ipywidgets.Play widget to any sliders that get created. If a boolean it will apply to all kwargs, if a dictionary you choose which sliders you want to attach play buttons too. If a list of strings use the names of the parameters that you want to have sliders

  • play_button_pos (str, or dict, or list(str)) – ‘left’ or ‘right’. Whether to position the play widget(s) to the left or right of the slider(s)

Returns

  • fig (matplotlib figure)

  • ax (matplotlib axis)

  • controls (list of widgets)