Problem
Running a Python script that uses matplotlib in PyCharm completes without errors, but no plot is shown: no separate plot window opens and nothing appears inside the IDE. fig.savefig() calls, when present, still write image files correctly.
Occurs with any interpreter type, including Anaconda and other conda environments, on all operating systems.
Cause
Three causes account for most cases:
- The plotting code never runs.
plt.show()is missing, commented out, or not reached (for example, the whole script is commented out). The script exits silently and all figures are discarded. - Plots are routed to the Plots tool window. When Show plots in tool window is enabled in Settings | Python | Plots, figures appear in the Plots tool window instead of separate windows. If that tool window is closed or hidden, it looks like nothing happened.
- A non-interactive matplotlib backend is active. When matplotlib resolves to the
Aggbackend (common in environments without a GUI toolkit binding),plt.show()draws nothing on screen by design.
Resolution
-
Confirm the plotting code actually executes: the script calls
plt.show(), the call is not commented out, and it is reached when the script runs. -
Run the script and check the Plots tool window inside PyCharm. The Show plots in tool window option in Settings | Python | Plots controls whether figures appear there or in separate windows. See Plots in the PyCharm documentation.
-
Check the active matplotlib backend by running the following with the same interpreter:
import matplotlib print(matplotlib.get_backend())If the output is
Agg, the environment has no interactive GUI backend; install a GUI toolkit binding (for example, PyQt or Tk) into the interpreter's environment or select a different backend. -
If plots still do not appear, collect the IDE logs via Help | Collect Logs and Diagnostic Data and attach them to a support request.
Comments
0 comments
Please sign in to leave a comment.