carbonian.org / manual pages
CARBONIAN-NOTEBOOK(1) Carbonian Manual CARBONIAN-NOTEBOOK(1)

carbonian-notebook - IPython with plots drawn in the terminal, in the palette's colours

carbonian-notebook [demo | console | FILE.py | IPYTHON-ARGS]

Starts IPython with a matplotlib backend that sends each figure to the terminal as a sixel picture (foot, and tmux 3.8) sized to the pane, in the colours of the current palette. With no argument it opens an IPython session; plt.show() draws the figures in the pane.

tmux keeps sixel pictures only on the visible screen: after a resize they are dropped, and they are not in the scrollback. In IPython, %figs shows the last 20 figures one at a time on a screen of their own (Right, n, j or space: next; Left, p or k: previous; g, G: first, last; q or Esc: leave), drawn again at every resize, and %replot (also %redraw) clears the screen and draws them again once. In the viewer, s saves the figure on show as a PNG file and S saves them all, in ~/Pictures/figures (or CARBONIAN_MPLSIXEL_SAVEDIR); the viewer fits the figure to the window keeping its proportion and shows a line about it. %savefigs [DIR] saves them without the viewer.

The same session, with five demo plots already drawn (lines, scatter, histogram, heatmap, a dark figure).
A Jupyter console instead of IPython (needs jupyter-console).
Run the file, then stay in IPython.
Run the notebook's code cells in order, cell by cell, by the kernel the notebook names (R: Rscript; Julia: julia with CairoMakie; anything else: IPython with the palette's matplotlib style), and show what each cell printed and drew: the notebook's Markdown cells, a line In [n] with the first line of the cell, its text output and its figures (as sixel, fitted to the pane). HTML tables are shown as text. An error in a cell is shown and the run goes on, as in Jupyter. A line on the terminal tells which cell is running. The run happens in a temporary tree that links the project's folders but has an empty docs/, so what a notebook exports there is thrown away. Also available as carbonian-nb. Options before the file:
Run nothing: show the output saved in the notebook file, its last run.
Open the result in carbonian-view, a page at a time with the arrows (text pages and one page per figure), instead of printing it.
Also show the code of each cell.
Only the figures: no text output, no cell titles, no Markdown cells. With --nav the viewer gets just the pictures, a page each.
Run the notebook as without --last and write the outputs back into the .ipynb file, as Jupyter's save does: the text of each cell, an error as an error output, the figures as image/png and the execution counts; everything else in the file is kept. After it, --last shows that run. It works for Python, R and Julia notebooks and goes with --nav, --figs and --code (they only change what is shown; the whole run is saved). The file is written atomically (a temporary file in the same folder, then a rename), so a failed run leaves the notebook as it was; a notebook that cannot be written (the packaged galleries in /usr/share are read-only) is refused before the run, and carbonian-gallery --copy DIR gives a copy to save into. --save with --last is refused (exit 2): that run executes nothing.

The backend; set it to use another one (default: module://carbonian_mplsixel).
A palette name, a file, or auto (the system's palette); applied when the backend loads.
Colours of the sixel picture (256).
yes (default): the figure is drawn at a dpi that fits the pane; no keeps its size.
WxH pixels, when the terminal does not say.

The package also ships a ggplot2 theme for R in the palette's colours and a way to print ggplot figures in the terminal as sixel pictures. Install the R packages first (they are only suggested, R is large): sudo apt install r-cran-ggplot2 r-cran-ragg Then /usr/lib/carbonian/notebook/carbonian_ggplot.py --install writes ~/.config/carbonian/ggplot.R and source("~/.config/carbonian/ggplot.R"); carbonian_sixel(TRUE) (in ~/.Rprofile to make it permanent) makes each plot print in the pane. R figures do not go through %figs; a PNG made with png() can be opened with carbonian-view(1).

A Julia notebook (a kernel named julia) is run cell by cell by jnb, which loads CairoMakie when a cell mentions Makie, saves each displayed Makie figure as a picture, and takes the palette from ~/.config/carbonian/makie.jl (theme_carbonian(); the palette hook 60-makie keeps it up to date). Julia is only suggested (it is large and not in Debian): install it from julialang.org or with juliaup, then carbonian-jnb --setup adds CairoMakie to the shared environment @carbonian. The notebook's own Project.toml wins when there is one. Make the theme file once with /usr/lib/carbonian/notebook/carbonian_makie.py --install. The 3D plots of Makie are pictures (no live turning).

The package sets R_PROFILE (/etc/environment.d/60-carbonian-r.conf, read at the next login) to /usr/lib/carbonian/R/Rprofile.site, which runs Debian's own Rprofile.site and then loads the palette for an interactive R (or when CARBONIAN_R_PALETTE is set: an Rscript that writes a PDF keeps its white page by default): base graphics and lattice at once, ggplot2's theme and scales when ggplot2 is attached. ~/.config/carbonian/ggplot.R wins when it exists. The generated files are kept in ~/.cache/carbonian/R, one pair per palette name, and made again when a new palette name shows up. CARBONIAN_PALETTE=off turns it off.

/usr/lib/carbonian/notebook
the backend, the style (carbonian_mplstyle), the R and plotnine themes and the demos.

carbonian-view(1), ipython3(1), carbonian-palette(1), tmux(1)

Carbonian