If your Matplotlib plots are showing up in a scrollable mini window (instead of a full, resizable window or inline in your IDE), it’s likely due to the backend that Matplotlib is using to render the plots.
Here's how to fix it depending on your environment:
✅ 1. Set the Backend to a Different One
In some environments, the default backend might be set to something like TkAgg, qt, or widget (e.g. ipympl), which can cause odd display behavior.
A. Change the backend in your script:
You can explicitly set the backend at the top of your script:
import matplotlib
matplotlib.use('TkAgg') # or 'QtAgg' or 'Agg' (for non-interactive), etc.
import matplotlib.pyplot as plt
Other common interactive backends to try:
'TkAgg'
'QtAgg'
'MacOSX' (on macOS)
'GTK3Agg'
B. For Jupyter Notebooks:
If you're using Jupyter or JupyterLab, running %matplotlib widget may be causing the issue (it creates an interactive plot widget that can show as a scrollable frame). Try switching to:
✅ 2. Use plt.show() at the End
If you're writing a script or running code where real-time rendering isn't triggered (as in bare Python scripts), make sure to include:
import matplotlib.pyplot as plt
# Your plotting code...
plt.plot([1, 2, 3], [4, 5, 6])
plt.show()
It's plt.show() that triggers the full rendering window if not run in an interactive environment.
✅ 3. Check Your Environment Settings
If you're using an IDE like VSCode, Spyder, or PyCharm, they can also affect how plots render:
-
Spyder:
- Go to
Tools → Preferences → IPython Console → Graphics.
- Change the backend from
Automatic or Inline to Qt5 or Tkinter.
-
VS Code:
- In Jupyter Notebooks, change the setting
Python > Data Science: Interactive Window Mode to Per File.
- Or change
%matplotlib widget to %matplotlib inline.
✅ 4. Reset Matplotlib Configuration
Sometimes, custom entries in your Matplotlib config file (matplotlibrc) can cause issues.
To check where this file is and/or reset:
python -c "import matplotlib; print(matplotlib.get_configdir())"
Then look for a file called matplotlibrc and either:
- Delete it
- Or comment out any suspicious backend setting like:
backend: TkAgg
Summary of Solutions
| Problem | Solution |
|---|
| Scrollable mini plot in Jupyter | %matplotlib inline |
| Unwanted interactive widget | Use non-widget backend like 'TkAgg' |
| Plot not showing | Add plt.show() |
| GUI environment causing small plot area | Switch backend (matplotlib.use()) or config in IDE |
| Configuration messed up | Reset matplotlibrc file |
If you're still having trouble, let me know:
- Your Python version
- Are you using Jupyter?
- Which IDE or terminal?
I can give more tailored help.