Python 3.9, tkinter gui, matplotlib, windows11. mne 1.3.1
Using python 3.8 plotting was smoooth. Now , when raw EEG plots in canvas inside a tk.Frame, the plot has its inferior part outside (bigger than) canvas, then I move gui a little or go canvas fullscreen the plot resizes correctly. bellow script.
Any suggestion or tip?
class EEGPlot:
def init(self):
pass
def plot_eeg(self, my_canvas, file_path):
# create an instance of the EEGPlot class
eeg_plot = EEGPlot()
eeg_plot.plot_eeg_canvas(my_canvas, file_path)
def plot_eeg_canvas(self, my_canvas,file_path):
# check if file path exists
if not os.path.isfile(file_path):
tk.messagebox.showerror("Error", f"File path {file_path} does not exist.")
return
# this says the start point in scrollbar plot() is zero (left) when reading EEG
start_var = 0
# Load raw data from file path using MNE-Python
raw = mne.io.read_raw_fif(file_path)
# Clear the plot and create a new figure
plt.clf()
fig_home = raw.plot(events=None, duration=12.0, start=start_var, n_channels=20, bgcolor='w', color=None,
bad_color=(0.8, 0.8, 0.8), event_color='cyan', remove_dc=True, order=None,
show_options=True, title=None, show=False, block=False, highpass=None, lowpass=None,
filtorder=4, clipping=1.5, show_first_samp=False, proj=True, group_by='type',
butterfly=False,
decim='auto', noise_cov=None, event_id=None, show_scrollbars=True, show_scalebars=True,
verbose=None)
fig_home.tight_layout()
# Create a canvas widget to display the figure
canvas_widget = FigureCanvasTkAgg(fig_home, master=my_canvas)
canvas_widget.draw()
# Configure the canvas widget to expand and fill the canvas frame
canvas_widget.get_tk_widget().place(relx=0, rely=0, relwidth=1, relheight=1)