Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

Matplotlib Plot Not Showing? Choose the Right Fix for VS Code, Jupyter or Scripts

Find out why a Matplotlib plot is missing and apply the right fix for a Python script, Jupyter notebook, or VS Code—without changing backends blindly.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check Matplotlib’s backend

A backend controls how Matplotlib renders figures: to a desktop GUI, notebook output, or a file. Check the active backend with:

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:

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.