Export and Display
Saving figures
All windows support kaxe.Window.save(). The output format is inferred from the file extension, or set explicitly with format=.
PNG (default)
PNG is the default raster format. Plots render at high resolution (default 2500×2000 pixels unless overridden via style(width=..., height=...)).
plt.save("figure.png")
SVG (2D plots and charts)
SVG export produces a self-contained vector file. Curves, axes, and labels are vector graphics. Math labels use fondi with embedded New Computer Modern fonts.
plt.save("figure.svg")
Note
SVG is supported for 2D plots, charts, and kaxe.Grid layouts. Individual kaxe.Plot3D windows save PNG only; in a grid, 3D cells are embedded as raster images inside the SVG. kaxe.Grid.show() always previews PNG.
grid = kaxe.Grid()
grid.addRow(plt1, plt2)
grid.save("figure_grid.svg")
When writing to a buffer without a filename extension, pass format explicitly:
from io import BytesIO
buf = BytesIO()
plt.save(buf, format="svg")
PNG and SVG can be saved from the same plot; saving SVG does not invalidate a cached PNG.
PDF (2D plots and charts)
PDF export produces a vector file with the same content as SVG. Math labels use Computer Modern fonts from fondi. Install the optional dependencies first:
pip install kaxe[pdf]
For 3D plots and PDF export together:
pip install kaxe[3d,pdf]
plt.save("figure.pdf")
Note
PDF follows the same rules as SVG: supported for 2D plots, charts, and kaxe.Grid layouts. Individual kaxe.Plot3D windows save a raster image inside a PDF page; in a grid, 3D cells are embedded as raster images inside the vector PDF.
grid = kaxe.Grid()
grid.addRow(plt1, plt2)
grid.save("figure_grid.pdf")
When writing to a buffer without a filename extension, pass format explicitly:
from io import BytesIO
buf = BytesIO()
plt.save(buf, format="pdf")
Display with show()
kaxe.Window.show() renders and displays the figure.
Terminal: opens the image with the system viewer (via Pillow).
Jupyter / IPython: detects the active shell and displays the image inline instead of opening an external viewer. Images are rendered in memory (no temporary files).
plt.show()
Auto-display in notebooks
In Jupyter and IPython, the plot object displays automatically when it is the last expression in a cell — no show() call needed:
plt = kaxe.Plot([-5, 5, -5, 5])
plt.add(kaxe.Function2D(lambda x: x**2))
plt
The same applies to kaxe.Grid and chart windows. Explicit show() still works.
For kaxe.Plot3D, auto-display and show(gui=False) produce a static raster snapshot. Interactive rotation requires plt.show(gui=True).
In notebooks, prefer show() or bare plt for quick previews and save() when you need a file for LaTeX inclusion.
Including figures in LaTeX
PNG — simple and widely compatible:
\\usepackage{graphicx}
...
\\includegraphics[width=0.8\\textwidth]{figures/parabola.png}
SVG — vector output with embedded Computer Modern math (requires \\usepackage{svg} or convert to PDF):
\\includesvg[width=0.8\\textwidth]{figures/parabola.svg}
PDF — vector output, widely compatible with \\includegraphics (requires pip install kaxe[pdf]):
\\includegraphics[width=0.8\\textwidth]{figures/parabola.pdf}
Tips for publication figures:
Use
plt.theme(kaxe.Themes.A4Medium)orplt.adjust(0.5)to match document font size — see StylingPrefer
.svgor.pdffor 2D plots in LaTeX documentsUse
kaxe.resetColor()before each figure if you need consistent colors across multiple saves in one script
Suppressing progress output
Kaxe logs bake progress to the terminal by default. In Jupyter, logging is automatically reduced. Progress bars appear only when baking takes longer than one second (configurable). To suppress progress bars and info messages globally:
kaxe.setSetting(removeInfo=True)
Notebook display settings
kaxe.setSetting(jupyterDisplayWidth=600) # inline image width in pixels
kaxe.setSetting(jupyterLoadingThreshold=2.0) # seconds before progress bar appears