Matplotlib.pyplot.disconnect() in Python

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
matplotlib.pyplot.disconnect() Function
The disconnect() function in pyplot module of matplotlib library is used to disconnect the callback with id cid.
Syntax: matplotlib.pyplot.disconnect(cid)
Parameters: This method accept the following parameters that are described below:
- cid: This parameter is used to disconnect the callback.
Below examples illustrate the matplotlib.pyplot.disconnect() function in matplotlib.pyplot:
Example #1:
| # Implementation of matplotlib function importnumpy as np importmatplotlib.pyplot as plt  fig, ax =plt.subplots() ax.plot(np.random.rand(10))  defonclick(event):     print('%s click: button =%d, x =%d, y =%d,\     xdata =%f, ydata =%f' %          ('double'ifevent.dblclick else'single',            event.button,            event.x,            event.y,             event.xdata,             event.ydata))  cid =fig.canvas.mpl_connect('button_press_event',                              onclick) fig.canvas.mpl_disconnect(cid)  plt.suptitle('matplotlib.pyplot.disconnect()\ function Example', fontweight ="bold")  plt.show()  | 
Output:
Example #2:
| # Implementation of matplotlib function frommatplotlib.backend_bases importMouseButton importmatplotlib.pyplot as plt importnumpy as np  t =np.arange(0.0, 1.0, 0.01) s =np.sin(2*np.pi *t) fig, ax =plt.subplots() ax.plot(t, s)   defgfg1(event):          # get the x and y pixel coords     x, y =event.x, event.y     ifevent.inaxes:                  # the axes instance         ax =event.inaxes         print('Coordinates : %f  and\         %f' %(event.xdata, event.ydata))   defgfg2(event):          ifevent.button isMouseButton.LEFT:         print('Successfully disconnected')         plt.disconnect(binding_id)   binding_id =plt.connect('motion_notify_event',                          gfg1)  plt.connect('button_press_event', gfg2)  plt.suptitle('matplotlib.pyplot.disconnect()\ function Example', fontweight ="bold") plt.show()  | 
Output:
Figure shown
Background result after click on figure
 
				 
					



