Skip to content
H.P. Gansevoort edited this page Sep 23, 2026 · 1 revision

Verso

Verso is an open-source notebook for C#, built to replace Polyglot Notebooks after Microsoft ended the runtime underneath them. MatPlotLibNet.Verso is the extension that teaches it to draw this library's charts.

Install it from Verso's Extensions panel — search for MatPlotLibNet.Verso. The charting library itself is an ordinary package: #r "nuget: MatPlotLibNet" at the top of a cell, or dotnet add package MatPlotLibNet in a project the notebook references.


The whole cell

#r "nuget: MatPlotLibNet"

using MatPlotLibNet;

Plt.Create()
   .WithTitle("Revenue")
   .AddSubPlot(1, 1, 1, ax => ax
       .SetXLabel("Quarter")
       .SetYLabel("€M")
       .Plot([1, 2, 3, 4], [12, 18, 15, 22], s => s.Label = "2026")
       .WithLegend())

There is nothing to import from the extension and nothing to call. The chart is the cell's last expression, and it draws inline as SVG.

Note what is not in that cell: .Build(). Plt.Create() hands back a builder, and a notebook shows whatever the cell ended on, so the builder is what usually arrives. It is drawn like a figure. So is Plt.Mosaic(), and so is a Figure you built earlier and kept in a variable.

Every chart the library draws works this way — 83 chart types, 148 colormaps, candlesticks with indicators, heatmaps, Sankey diagrams, 3-D surfaces, map projections. The extension draws none of them itself: it hands the library's own SVG to the notebook, so a chart in a cell is the same picture as a chart in a file.


How big the picture gets

The chart fills the width of the cell and keeps its proportions; the SVG carries a viewBox, so there is nothing to set.

Height is the one case that needs a decision. A figure taller than the cell can show gets a scroll box — it is not resized. Rewriting the height would re-run the layout, and a chart drawn at a size nobody chose is worse than one you scroll: twelve rows of labels squeezed into the space for four.

A cell that asks for image/svg+xml gets the SVG bare, with no HTML around it. The default, text/html, is the one that keeps the links, the accessible name and the responsive width.


When a chart cannot be drawn

The cell says so in words, carrying the message from the renderer itself rather than a stack trace from inside the charting library:

MatPlotLibNet could not draw this chart. All rows must have the same length. Row 0 has 2 cells; row 1 has 3. (Parameter 'pattern')

If a cell hands over something that is not a chart at all, the extension says that too, and names what it got.


Why the package is only the extension

A notebook installs an extension by copying the package and its dependencies into one folder, and loads that folder in its own collectible AssemblyLoadContext. If the charting library were shipped alongside, it would be loaded a second time there — and the extension's Figure would be a different type from the Figure the cell made. Same name, different identity, and a typeof comparison that is false forever.

So MatPlotLibNet.Verso references nothing but Verso.Abstractions. It matches a chart by name and renders it through the assembly the cell's own value came from. That is also why the package is a few kilobytes.


Package details

Install Verso → Extensions panel → MatPlotLibNet.Verso
Target framework net8.0
Dependencies Verso.Abstractions only, pinned exactly
Draws Figure, FigureBuilder, MosaicFigureBuilder
Answers for text/html (default) and image/svg+xml

See also: Notebooks for the Polyglot and Jupyter package that came before it, and the cookbook page.

Clone this wiki locally