Slow/no reactivity at all when buttons are pressed/mouse is clicked

OS (e.g. Win10): Windows 10
PsychoPy version (e.g. 1.84.x): 2022.2.5

Description of the experiment and problem I am facing
I’m trying to run an experiment in which the main part consists of routines that need to be refreshed the whole time and display different things depending on what the participant does by clicking on different buttons until they hit the “next” button to continue to the next routine. Everything works fine except that in many cases when I click on the buttons, nothing happens and I need to re-click several times until the supposed outcome is presented. This gets worse throughout the experiment, but does not happen in all cases. I was wondering whether the problem is the overload in the distinct routines and different frames but don’t know how to solve the issue without using the coder of PsychoPy (which might exceed my capabilities).

The problematic routines consist of:

  • a timer that is running in form of a diminishing rectangle
  • four to six images that are being created, saved and uploaded whenever participants click on a button (suggested by this thread Drawing a Matplotlib plot to the Psychopy window; didn’t know how to present (bar) plots differently)
  • the plots depend on how the participants moved two to three sliders before hitting the “run” button
  • lines that appear (size changes from (0,0) to a specific size) between two consecutive buttons whenever they are being pressed in a row (four to six buttons and nine lines)

The main experiment consists of a sequential loop that consists of two of these routines (in a slightly different version) plus some instruction routines and that reads the variables file which at the moment consists of five rounds (different tasks with different cover stories and variable dependencies).

What did you try to make to fix the inital problem?:
I considered that maybe the button component is not working properly so I created a mouse component. Whenever the mouse was clicked on a text box that resembled the button, the respective things would happen (e.g. continuing to the next routine).
if mouse.isPressedIn(button_next):
continueRoutine = False
But this didn’t change a thing: clicking on the textbox was also delayed or needed several attempts.

How I hope help can be provided:

  • how could I draw/change plots on screen without saving it as an image first and uploading it again? Because I believe this is the main issue
  • but maybe there is a general problem I did not consider (e.g. frame rate)? I imagine there must be larger experiments that use different e.g. video stimuli and do not seem to have this issue with no reactivity.

Example code for creating one of the plots:
#at beginning of routine
#input 1
plt.ylim([-2.1, 2.1])
plt.xlim([0, 10])
graph4 =, 0)

frame4 = plt.gca()


#when the run button is pressed:
counter += 1
turn += 1

variX += eigenX
variY += eigenY
variZ += eigenZ

if exp_sliderA.markerPos == 3.0:
input1 = 0.1
elif exp_sliderA.markerPos == 1.0:
variX -= (2X_inputA)
variY -= (2
variZ -= (2Z_inputA)
input1 = -2
elif exp_sliderA.markerPos == 2.0:
variX -= X_inputA
variY -= Y_inputA
variZ -= Z_inputA
input1 = -1
elif exp_sliderA.markerPos == 4.0:
variX += X_inputA
variY += Y_inputA
variZ += Z_inputA
input1 = 1
elif exp_sliderA.markerPos == 5.0:
variX += (2
variY += (2Y_inputA)
variZ += (2
input1 = 2

if exp_sliderB.markerPos == 3.0:
input2 = 0.1
elif exp_sliderB.markerPos == 1.0:
variX -= (2X_inputB)
variY -= (2
variZ -= (2Z_inputB)
input2 = -2
elif exp_sliderB.markerPos == 2.0:
variX -= X_inputB
variY -= Y_inputB
variZ -= Z_inputB
input2 = -1
elif exp_sliderB.markerPos == 4.0:
variX += X_inputB
variY += Y_inputB
variZ += Z_inputB
input2 = 1
elif exp_sliderB.markerPos == 5.0:
variX += (2
variY += (2Y_inputB)
variZ += (2
input2 = 2

if exp_sliderC.markerPos == 3.0:
input3 = 0.1
elif exp_sliderC.markerPos == 1.0:
variX -= (2X_inputC)
variY -= (2
variZ -= (2Z_inputC)
input3 = -2
elif exp_sliderC.markerPos == 2.0:
variX -= X_inputC
variY -= Y_inputC
variZ -= Z_inputC
input3 = -1
elif exp_sliderC.markerPos == 4.0:
variX += X_inputC
variY += Y_inputC
variZ += Z_inputC
input3 = 1
elif exp_sliderC.markerPos == 5.0:
variX += (2
variY += (2Y_inputC)
variZ += (2
input3 = 2

#update lists that are being presented in the graphs
Inputs1.append(input1) #the only needed for the example plot input A

#input A
fig4, ax4 = plt.subplots(1)

if counter > 7:
l = l + 1
plt.xlim([l, 10+i])
elif counter <=7:
plt.xlim([0, 10+i])

graph4 =, Inputs1)
frame4 = plt.gca()
graph4=plt.ylim([-2.1, 2.1])