When a Matplotlib plot does not appear, first identify where the code is running: a standalone Python script, a Jupyter notebook, or a VS Code notebook or Interactive Window. Then confirm the code ran, the right Python environment or kernel is selected, and Matplotlib is using a backend suited to that context. A missing desktop window may be expected with a non-interactive backend; missing notebook output points first to cell execution, kernel selection, or hidden output.
Start by checking what ran and where
A figure can be created without being displayed. Before changing Matplotlib settings, verify that the file or cell containing the plotting code actually executed and that execution reached the plotting lines.
As an Amazon Associate I earn from qualifying purchases.
- In a script: Make sure you are running the file you edited and that no earlier error stops execution.
- In a notebook: Rerun the cell and inspect its output area for an exception or other output.
- In a VS Code notebook: Confirm a kernel is selected and that it is the environment where Matplotlib is installed.
VS Code can use Python environments, Jupyter kernels, or an existing Jupyter server as notebook kernel sources. See Microsoft’s Jupyter kernel management documentation and Python environments documentation.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsCheck Matplotlib’s backend
A backend controls how Matplotlib renders figures: to a desktop GUI, notebook output, or a file. Check the active backend with:
#1 Best Overall
import matplotlib
print(matplotlib.get_backend())
For example, Agg is a non-interactive backend. Matplotlib may select it on Linux when it cannot connect to an X or Wayland display, so code can create a figure without opening a window. In that situation, use a file output or fix the display and GUI-toolkit setup rather than expecting a pop-up. See the Matplotlib backend guide.
Use the display method that fits your context
Standalone Python script
A script generally needs an explicit plt.show() call to display a figure:
Rank #2
import matplotlib.pyplot as plt
plt.plot([1, 4, 6])
plt.show()
If this creates no window, check the backend and whether its GUI toolkit is installed and working. Matplotlib’s backend guide includes a small toolkit test for investigating installation problems.
Free tools Windows power users keep installed
One-click scans. No signup required.
Jupyter notebook
Jupyter’s inline backend renders a static image when the cell runs. The notebook backends inline, notebook, and widget call show() at the end of each cell by default. Start by confirming the cell ran and its output is visible; changing the backend will not fix a cell that never executed or output that is hidden.
For interactive notebook figures, Matplotlib documents the separately installed ipympl package. In a supported notebook, use %matplotlib widget or %matplotlib ipympl after installing it. The interactive figures guide covers the notebook options.
VS Code notebook or Python Interactive Window
Run the cell or code cell, then inspect its notebook output or the Python Interactive Window. The Interactive Window supports Matplotlib plots, which can also be opened in the Plot Viewer; see Microsoft’s Python Interactive Window documentation. For notebooks, check whether Workspace Trust and Restricted Mode are affecting rich outputs.
Rank #4
Choose the right route for the result you need
| Need | Suitable path | Trade-off or check |
|---|---|---|
| Display a plot from a normal script | Interactive GUI backend and plt.show() |
Needs a working GUI toolkit and display connection. |
| See a quick result in Jupyter | Default inline output | Produces a static image, not GUI interactivity. |
| Interact with a notebook figure | ipympl widget backend |
Requires the separate ipympl package and notebook support. |
| Generate an image in batch or headless mode | Non-interactive backend and savefig() |
Writes a file rather than opening an on-screen window. |
| Run cells in VS Code | Selected kernel or environment, with notebook or Interactive Window output | Confirm the intended kernel and that rich output is not hidden in Restricted Mode. |
Save a plot to a file instead of opening a window
For a headless run or when an image file is what you need, save the figure:
plt.savefig("plot.png")
If the file seems missing, check the process’s current working directory and the filename. If you also call blocking plt.show(), save first: Matplotlib’s pyplot documentation warns that saving after a blocking show can save a new, empty figure. See the show() reference.
Change the backend only when diagnosis points to it
Matplotlib can select a backend through rcParams, the MPLBACKEND environment variable, or matplotlib.use(); the last setting takes precedence. If a script needs an explicit backend, call matplotlib.use(...) before creating any figures. Matplotlib cautions against setting MPLBACKEND globally because it can produce counterintuitive behavior. When the actual problem is the wrong environment or an unavailable GUI toolkit, fix that cause instead of forcing a backend. See the backend configuration guidance.
Matplotlib’s stable backend guide advises notebook and IDE users to consult the relevant environment’s documentation when figures do not work there. Details can vary with Matplotlib, notebook, and VS Code versions, so check the linked official guidance if your setup behaves differently.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →




