def my_callback(ax, ch_idx):
 ax.plot(freqs, psds[ch_idx], color='red')
 ax.set_xlabel = 'Frequency (Hz)'
 ax.set_ylabel = 'Power (dB)'

def my_callback ( ax , ch_idx ) : ax . plot ( freqs , psds [ ch_idx ] , color = 'red' ) ax . set_xlabel = 'Frequency (Hz)' ax . set_ylabel = 'Power (dB)'
this block of code is executed once you click on one of the channel axes in the plot .