MatPlotLibNet 0.2.0
See the version list below for details.
dotnet add package MatPlotLibNet --version 0.2.0
NuGet\Install-Package MatPlotLibNet -Version 0.2.0
<PackageReference Include="MatPlotLibNet" Version="0.2.0" />
<PackageVersion Include="MatPlotLibNet" Version="0.2.0" />
<PackageReference Include="MatPlotLibNet" />
paket add MatPlotLibNet --version 0.2.0
#r "nuget: MatPlotLibNet, 0.2.0"
#:package MatPlotLibNet@0.2.0
#addin nuget:?package=MatPlotLibNet&version=0.2.0
#tool nuget:?package=MatPlotLibNet&version=0.2.0
MatPlotLibNet
A .NET 10 charting library inspired by matplotlib. Fluent API, dependency injection, parallel SVG rendering, polymorphic export (SVG/PNG/PDF), and multi-platform output to Blazor, MAUI, ASP.NET Core, Angular, and standalone browser popups.
Packages
| Package | Install | What it does |
|---|---|---|
| MatPlotLibNet | dotnet add package MatPlotLibNet |
Core: models, fluent API, SVG rendering, JSON serialization, transforms |
| MatPlotLibNet.Skia | dotnet add package MatPlotLibNet.Skia |
PNG and PDF export via SkiaSharp |
| MatPlotLibNet.Blazor | dotnet add package MatPlotLibNet.Blazor |
MplChart + MplLiveChart Razor components with SignalR |
| MatPlotLibNet.AspNetCore | dotnet add package MatPlotLibNet.AspNetCore |
REST endpoints, SignalR hub, IChartPublisher |
| MatPlotLibNet.Maui | dotnet add package MatPlotLibNet.Maui |
Native MplChartView control via Microsoft.Maui.Graphics |
| MatPlotLibNet.Interactive | dotnet add package MatPlotLibNet.Interactive |
figure.ShowAsync() opens default browser with live updates |
| @matplotlibnet/angular | npm install @matplotlibnet/angular |
Angular components + TypeScript SignalR client |
Quick start
using MatPlotLibNet;
using MatPlotLibNet.Styling;
double[] x = [1, 2, 3, 4, 5];
double[] y = [2, 4, 3, 5, 1];
// Fluent API -> SVG string
string svg = Plt.Create()
.WithTitle("My Chart")
.WithTheme(Theme.Seaborn)
.Plot(x, y, line => { line.Color = Color.Blue; line.Label = "sin(x)"; })
.Build()
.ToSvg();
// Polymorphic export via transforms
using MatPlotLibNet.Transforms;
var figure = Plt.Create().Plot(x, y).Build();
figure.Transform(new SvgTransform()).ToFile("chart.svg");
figure.Transform(new PngTransform()).ToFile("chart.png"); // requires MatPlotLibNet.Skia
figure.Transform(new PdfTransform()).ToFile("chart.pdf"); // requires MatPlotLibNet.Skia
Chart types
16 series types with fluent builder API:
var fig = Plt.Create()
.Plot(x, y) // line
.Scatter(x, y, s => s.MarkerSize = 8) // scatter
.Bar(["Q1", "Q2", "Q3"], [100, 200, 150]) // bar
.Hist(measurements, bins: 20) // histogram
.Pie([40, 30, 20, 10], ["A", "B", "C", "D"]) // pie
.Step(x, y, s => s.StepPosition = StepPosition.Post) // step function
.FillBetween(x, y) // area / fill between
.ErrorBar(x, y, errLow, errHigh) // error bars
.Build();
Additional types via AxesBuilder.AddSubPlot:
Heatmap, Box, Violin, Contour, Stem, Candlestick, Quiver, Radar.
Stacked bars
.AddSubPlot(1, 1, 1, ax => ax
.SetBarMode(BarMode.Stacked)
.Bar(["A", "B"], [10.0, 20.0])
.Bar(["A", "B"], [5.0, 10.0]))
Annotations and decorations
.AddSubPlot(1, 1, 1, ax => ax
.Plot(x, y)
.Annotate("peak", 2.0, 4.0, a => { a.ArrowTargetX = 1.5; a.ArrowTargetY = 3.5; })
.AxHLine(3.5, l => l.Color = Color.Red) // horizontal reference line
.AxVLine(2.0) // vertical reference line
.AxHSpan(3.0, 4.0, s => s.Alpha = 0.1) // shaded horizontal region
.AxVSpan(1.5, 2.5)) // shaded vertical region
Secondary Y-axis (TwinX)
.AddSubPlot(1, 1, 1, ax => ax
.Plot(time, temperature)
.SetYLabel("Temperature (C)")
.WithSecondaryYAxis(sec => sec
.SetYLabel("Humidity (%)")
.Plot(time, humidity, s => s.Color = Color.Orange)))
Subplots
var fig = Plt.Create()
.WithSize(1200, 600)
.AddSubPlot(1, 2, 1, ax => ax
.WithTitle("Temperature")
.SetXLabel("Time").SetYLabel("Celsius")
.Plot(time, temp)
.ShowGrid())
.AddSubPlot(1, 2, 2, ax => ax
.WithTitle("Distribution")
.Hist(samples, bins: 15))
.Build();
Subplots render in parallel -- each gets its own SVG context, merged in order.
Export transforms
All output formats share the IFigureTransform interface with a fluent TransformResult:
using MatPlotLibNet.Transforms;
// Polymorphic -- same pattern for any format
figure.Transform(new SvgTransform()).ToFile("chart.svg");
figure.Transform(new PngTransform()).ToFile("chart.png");
figure.Transform(new PdfTransform()).ToFile("chart.pdf");
// Or get bytes / write to stream
byte[] png = figure.Transform(new PngTransform()).ToBytes();
figure.Transform(new SvgTransform()).ToStream(stream);
// Convenience shortcuts still work
string svg = figure.ToSvg();
byte[] pngBytes = figure.ToPng();
byte[] pdfBytes = figure.ToPdf();
SVG interactivity
// Native browser tooltips on hover
.AddSubPlot(1, 1, 1, ax => ax.WithTooltips().Scatter(x, y))
// Zoom (mouse wheel) and pan (click-drag) via embedded JavaScript
Plt.Create().WithZoomPan().Plot(x, y).Build()
Dependency injection
Rendering and serialization are interface-based:
// ASP.NET Core -- all services registered automatically
builder.Services.AddMatPlotLibNetSignalR();
// Console apps -- static defaults via ChartServices
string svg = ChartServices.SvgRenderer.Render(figure);
string json = ChartServices.Serializer.ToJson(figure);
// Replace with custom implementations
ChartServices.Serializer = new MyCustomSerializer();
Interfaces: IFigureTransform, IChartRenderer, ISvgRenderer, IChartSerializer, IChartPublisher.
Themes
| Theme | Style |
|---|---|
Theme.Default |
White background, classic matplotlib |
Theme.Dark |
Dark gray, light text |
Theme.Seaborn |
Light gray, statistical |
Theme.Ggplot |
R ggplot2 |
Theme.Bmh |
Bayesian Methods |
Theme.FiveThirtyEight |
Journalism |
Custom themes with immutable records:
var theme = Theme.CreateFrom(Theme.Dark)
.WithBackground(Color.FromHex("#1a1a2e"))
.WithFont(f => f with { Family = "Consolas", Size = 14 })
.WithGrid(g => g with { Visible = true, Alpha = 0.3 })
.Build();
Real-time charts
Server (ASP.NET Core):
await publisher.PublishSvgAsync("sensor-1", figure);
Blazor:
<MplLiveChart ChartId="sensor-1" HubUrl="/charts-hub" />
Angular:
<mpl-live-chart [chartId]="'sensor-1'" [hubUrl]="'/charts-hub'"></mpl-live-chart>
Both use IChartSubscriptionClient -- same SignalR protocol, different implementations (C# / TypeScript).
Interactive browser popup
using MatPlotLibNet.Interactive;
var handle = await figure.ShowAsync(); // opens default browser
await handle.UpdateAsync(); // pushes live updates
Architecture
MatPlotLibNet (Core) zero external dependencies
|
+-- MatPlotLibNet.Skia PNG + PDF export via SkiaSharp
+-- MatPlotLibNet.Blazor Razor components + C# SignalR client
+-- MatPlotLibNet.AspNetCore REST endpoints + SignalR hub
| +-- MatPlotLibNet.Interactive embedded Kestrel + browser popup
+-- MatPlotLibNet.Maui native GraphicsView rendering
+-- @matplotlibnet/angular Angular components + TS SignalR client
See ARCHITECTURE.md for the full rendering pipeline, data flow, and design patterns.
License
GPL-3.0 -- Copyright (c) 2026 H.P. Gansevoort
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on MatPlotLibNet:
| Package | Downloads |
|---|---|
|
MatPlotLibNet.Skia
PNG and PDF export for MatPlotLibNet charts using SkiaSharp. |
|
|
MatPlotLibNet.Blazor
Blazor components for MatPlotLibNet charting library. Renders charts as inline SVG. |
|
|
MatPlotLibNet.AspNetCore
ASP.NET Core endpoint helpers for MatPlotLibNet. Serves chart JSON specs for Angular and other SPA frameworks. |
|
|
MatPlotLibNet.Maui
MAUI controls for MatPlotLibNet charting library. Renders charts via Microsoft.Maui.Graphics. |
GitHub repositories
This package is not used by any popular GitHub repositories.