I have a function that plots a set of data with some points highlighted (the computer-measured values) and asks for user inputs about those points (the theoretical values for those points) in order to calibrate a device.
This used to work fine. Now, however, without changing anything, the plot doesn't show up until the end of the function. Here is an example of my code (I am running in jupyter notebook):
plot_peaks takes data and returns the x-coordinates of the peaks, as well as a plot of the data with the peaks highlighted.
%matplotlib qt
def func(data):
plot_points = plot_peaks(data) # plot_peaks returns a list of points that gets saved as plot_points AND plots peaks in a window
for number, point in enumerate(plot_points):
print("What is the coordinate of point %f?" %(number)) # ask user for the theoretical coordinate of the recorded peak
answer = input("> ")
function_that_saves_user_inputs # placeholder function to save lines
return user_inputs_vs_plot_points # dictionary
The user needs the plot to be able to see what the peaks are so that they can enter the theoretical value. However, the plot does not show up until all of the data points have been entered by the user.
If I use:
%matplotlib inline
then the plot shows up before the user enters anything. But I can't plot inline.
Things I've tried:
- using
ion()inside of plot_peaks (changes nothing) plt.show(block=False)inside of plot_peaks (changes nothing)- adding another
plt.show()inside offunc()(pops up a blank window, when function terminates then the desired plot shows up in a new window) - changing the backend