I would like to use tk.filedialog.askopenfilename() to prompt for a file name. However, after doing this the Sciplot figures are the wrong size. I have not found a solution, but did try some suggestions like using root.destroy(). They did not help. This is a test case that demonstrates the problem. (It doesn’t use the result of askopenfilename(), but just has a simple plot.)
The plot is the wrong size (very small). If the lines involving tk are not used (False instead of True in the test case), it works as expected.
import tkinter as tk
from tkinter import filedialog
import matplotlib.pyplot as plt
if True:
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename()
root.destroy()
plt.figure(figsize=(10,6))
y = range(1,10)
plt.plot(y)
plt.show()
This is on Windows 10 with Matplotlib 3.5.1 and Python 3.10. It is with a high resolution monitor (250%).