Skip to content

Outputs and images

An inline matplotlib figure, zoomed with zi

jOtter shows cell outputs directly under each cell, as JupyterLab does, and saves them in the notebook.

Printed text and results appear as plain text, with ANSI colours kept. Errors show the kernel’s traceback, coloured.

Output follows Jupyter’s rules for streams:

  • Consecutive print output merges into one block, as JupyterLab saves it.
  • A carriage return (\r) overwrites the current line, so progress bars such as tqdm update in place instead of printing a thousand lines.
  • clear_output() clears the cell’s output, including clear_output(wait=True).
  • Display handles work: display(obj, display_id=True) returns a handle whose .update() replaces that output wherever it is shown. tqdm.notebook uses this.
tqdm and display handles updating in place

Each cell keeps at most the last 10,000 lines of stream output, so a runaway loop can’t swamp memory.

Y copies the selected cell’s output text (printed text, results and tracebacks, without the colours) to the system clipboard, through the terminal’s OSC 52 support.

Outputs taller than 15 rows (the max_output_rows setting) are shown in a scrollable viewport. While a cell is running, the viewport sticks to the newest line.

Key Does
[ ] Scroll the selected cell’s output up / down
mouse wheel over the output Scroll it
o Collapse or expand the output
c Clear the selected cell’s output
C Clear all outputs

Clearing can be undone with u.

PNG, JPEG, GIF and SVG outputs render inline. That covers matplotlib, seaborn, plotnine, PIL images and anything else that displays an image.

Images use the terminal’s graphics protocol, which jOtter requires. See Terminal setup.

An image is shown at its own size, scaled so that it is as large next to the text as in JupyterLab, and scaled down to the window’s width when it is wider. On a HiDPI screen that enlarges a plain figure, which softens it; matplotlib’s retina format takes the same space and stays sharp: run %config InlineBackend.figure_format = 'retina' in a notebook, or set figure_format = "retina" to have jOtter do it for every Python kernel. Set image_scale to 1 to show images pixel for pixel. To keep tall images from pushing the next cell off the screen, set a height limit with max_image_rows.

Plotting libraries draw black on white, which is a glaring box on a dark terminal. jOtter shows such plots in your terminal’s colours instead: the white background becomes the terminal’s background, black text and axes become its foreground, and coloured lines and markers keep their hue. On a light terminal, plots look almost unchanged.

This only changes what you see in jOtter. The notebook’s saved outputs, files written with savefig, and what collaborators see in JupyterLab keep their original colours, and your plotting code needs no styling.

jOtter looks at each image and picks one of three treatments:

The image What jOtter does
At least a third of it is white, and it has no transparency: an ordinary plot Recolours the whole image
Less white than that, but white all around the edge: a picture in a white frame, such as imshow with axes Recolours the frame, its text and its ticks; the picture keeps its colours
Anything else: photos, and figures you’ve styled yourself with a transparent or dark background Shows it as it is

Recolouring swaps light and dark and keeps the hue. White becomes the terminal’s background and black its foreground; a dark blue line becomes a light blue line, so it stays readable on a dark background.

This has a side effect for plots that contain a picture and are mostly white, such as a heatmap with a colour bar or a grid of small images. The picture is recoloured with the rest: a colour map runs from light to dark instead of dark to light, and a grayscale image looks like a negative. The colour bar changes the same way, so readings stay correct.

To see every image exactly as the kernel sent it, set recolor_plots to false and restart jOtter:

~/.config/jotter/config.toml
recolor_plots = false

jOtter asks the terminal for its colours at startup. Terminals that don’t answer, which is rare, get the original images.

Key Does
zi Show the selected cell’s image fullscreen (zoom image); any key returns
Z Toggle showing the selected cell’s images pixel for pixel: no scaling, so a plain figure gets smaller and sharper, a retina one larger, and anything wider than the window is cropped
  • text/latex outputs, for example from SymPy, render as equations. See Math and LaTeX.
  • text/markdown outputs, for example from IPython.display.Markdown, render like markdown cells.
  • For everything else, jOtter shows the plain-text version the kernel sends along with it. A pandas DataFrame shows as its text table.
  • When an output has no text version at all, such as an HTML-only output, jOtter shows its type, [text/html], as a placeholder. The output is still kept in the notebook. ipywidgets are not interactive; they show as their text version or a placeholder.

See Notebook compatibility for the full list.