QtConsole Inline Graphics
QtConsole can render plots in the console window instead of opening separate figures. With the inline (Qt) backend, matplotlib figures appear inside the console's output area, so code and chart stay together in one window.
Enabling the Inline Qt Backend
# inside the attached qtconsole:
%matplotlib qt5
# or for the non-popping "inline in console" behavior:
# the console backend renders figures in the output pane
Plotting in the Console
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0, 2 * np.pi, 200)
plt.figure()
plt.plot(t, np.sin(t))
plt.title("Sine")
plt.show()
With the Qt backend, plt.show() displays the figure inside the console (or as a linked window, depending on backend variant) rather than requiring a notebook cell.
Backend Options
| Backend | Behavior |
|---|---|
| %matplotlib qt5 / qt | Qt figure windows, event loop integrated with the console |
| %matplotlib inline | static image output (works in notebooks; in console shows a saved/inline image) |
| %matplotlib auto | picks the best backend for the environment |
Limitations
- Interactive tools (zoom, pan) work with the Qt window backends; static inline images do not.
- Remote kernels render on the server; you need an X11 forwarding or display setup for Qt windows to appear locally, or use a backend that sends images back over the wire.
- Keep figure counts reasonable - a long session with hundreds of figures slows the console.
Workflow Tip
For exploratory plotting with a remote kernel, a pragmatic pattern is: plot in the console with the Qt backend for live iteration, and save the final figure to a file (plt.savefig) to bring it into the notebook or a report.
Summary
Use %matplotlib qt5 (or qt) in qtconsole to draw matplotlib figures inside the console's display area or linked Qt windows, so interactive plotting works without a browser. For remote kernels, X11 forwarding is needed for local windows, and saving figures to files is the reliable way to move results into notebooks and reports.