ginput from matplotlib in JupyterLab does not work

1.2k Views Asked by At

According to https://www.geeksforgeeks.org/matplotlib-pyplot-ginput-in-python/ the ginput function in Python is given by the following code:

%matplotlib widget 

import matplotlib.pyplot as plt
import numpy as np
t = np.arange(10)
   
plt.plot(t, np.sin(t))
     
plt.title('matplotlib.pyplot.ginput()\
 function Example', fontweight ="bold")
   
print("After 3 clicks :")
x = plt.ginput(3)
print(x)
   
plt.show()

The only modification for jupyterlab that I inserted is the magic function

%matplotlib widget 

at the beginning of the script. However, I do not get ginput() to work in Jupyterlab. It does not yield any errors, just no Figure appears, where I could click with the mouse. The output of ginput() accordingly is empty. In other Python IDE's, it works flawlessly (e.g. Thonny).

Did anybody get the ginput() function to work in Jupyterlab?

0

There are 0 best solutions below