MatPlotLibNet 标志

MatPlotLibNet

社区
xkqg

matplotlib for .NET: a C# charting library that draws 83 chart types and saves them as SVG, PNG, PDF or an animated GIF, straight from your server code. Fluent API, dependency injection, an MCP server for AI agents, and native controls for Blazor, WPF, MAUI, Avalonia, Uno and ASP.NET Core. No JavaScript framework, no WebView, no hosted service

发布者xkqg
代码仓库MatPlotLibNet
语言C#
复刻数
3
星标数
14
可用工具
0
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    MatPlotLibNet 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 14 个 Star 和 3 个 Fork。

MatPlotLibNet — matplotlib for .NET

MatPlotLibNet is a charting library for C#, .NET 10 and .NET 8, inspired by matplotlib. It draws 83 chart types and saves them as SVG, PNG, PDF or an animated GIF, straight from your server code. It does not need a JavaScript framework, a WebView or a hosted service.

It has a fluent API and it works with dependency injection. It ships with 148 colormaps, 30 themes, 13 map projections with embedded Natural Earth data, LaTeX-style MathText, text in any script, O(1) streaming with 53 technical indicators, a control room (Plt.OpsDashboard() — KPI tiles, state timelines, one shared trend window), and an MCP server so an AI agent can draw with it. Charts render natively in Blazor, WPF, MAUI, Avalonia, Uno and ASP.NET Core, and TypeScript clients are there for Angular, React and Vue.

CI NuGet NuGet Downloads License: MIT GitHub stars

Where this is going

1.17.1 is a patch on top of it. A clicked data point now reaches your own code — the desktop controls and the SignalR route both hand it over with its series, its value and where it was. The control room gained a service-topology panel, GroupedBar draws several bars per category in one call, DensityScatter colours a scatter by how crowded it is, and three accessible colour sequences arrived (petroff6, petroff8, petroff10). All fourteen packages carry an icon and release notes now, and the documentation site has a page that translates matplotlib into C#, call by call.

1.17 draws text in any script. Arabic letters join, Hebrew reads right to left, and a number or a Latin word inside Arabic or Hebrew text is placed in the correct position, using the font that ships in the package. The Unicode bidi algorithm is implemented in full and checked against Unicode's own 861,948 test cases; HarfBuzz shapes each run. Other scripts need a font file: SkiaFonts.Register(path) registers one, and the MCP server reads font files from the MATPLOTLIBNET_FONTS variable. Latin text is now kerned too, so text widths changed by up to 2 px per letter pair.

1.16 adds a data table beside every chart, for a reader who cannot see the picture. figure.ToDataTables() returns the figure's data as tables with typed columns, and you can write each table as HTML, Markdown or CSV. Every host serves the table: an ASP.NET Core endpoint next to the SVG endpoint, a ShowDataTable option on the Blazor component, a chartDataTable field in the GraphQL schema, and a fifth MCP tool. The same release fixed the streaming series. A point and a candle are now stored as one value, so a snapshot can no longer show a point or a bar that never existed. The buffer behind them is now the generic RingBuffer<T>.

1.15 added support for AI agents. MatPlotLibNet.Mcp is a Model Context Protocol server. A model can render any of these chart types from a JSON spec and look at the result. When the spec is wrong, the server reports which field is wrong instead of returning a blank picture.

1.14 added the control room: Plt.OpsDashboard() and the tile anatomy arrived with it. The releases since then contain the fixes and extensions that real control-room use required: a secondary Y axis with the same capabilities as the primary axis, streaming that draws in SVG, 3-D axis titles that do not overlap their own labels, tile captions that wrap and stay inside their tile, and an ops window whose ticks are formatted as time.

After that, releases follow what the community needs: bug fixes, documentation, and whatever comes up in real use. Open a Discussion or an Issue; that is what decides the next release. Every release, with its migration notes, is listed in the CHANGELOG.

Quality bar: every class must pass a strict coverage gate of ≥90 % line and branch coverage (706 classes, at 99.6 % line / 97.5 % branch) across 11,757 tests. The test suite verifies rendering against matplotlib pixel-fidelity fixtures.


Documentation


Packages

PackageInstallWhat it does
MatPlotLibNetdotnet add package MatPlotLibNetCore: models, fluent API, SVG rendering, JSON, transforms
MatPlotLibNet.DataFramedotnet add package MatPlotLibNet.DataFrameMicrosoft.Data.Analysis.DataFrame extension methods — plot, indicators (SMA/EMA/RSI/MACD/…), and polynomial regression from named columns
MatPlotLibNet.Skiadotnet add package MatPlotLibNet.SkiaPNG, PDF, and animated GIF export via SkiaSharp
MatPlotLibNet.Blazordotnet add package MatPlotLibNet.BlazorMplChart + MplLiveChart Razor components with SignalR
MatPlotLibNet.AspNetCoredotnet add package MatPlotLibNet.AspNetCoreREST endpoints, SignalR hub, IChartPublisher
MatPlotLibNet.Interactivedotnet add package MatPlotLibNet.Interactivefigure.ShowAsync() — browser popup, no server needed
MatPlotLibNet.GraphQLdotnet add package MatPlotLibNet.GraphQLGraphQL queries + subscriptions via HotChocolate
MatPlotLibNet.Mauidotnet add package MatPlotLibNet.MauiNative MplChartView via Microsoft.Maui.Graphics
MatPlotLibNet.Avaloniadotnet add package MatPlotLibNet.AvaloniaNative MplChartControl for Avalonia 12 — Skia backend, optional local interaction
MatPlotLibNet.Unodotnet add package MatPlotLibNet.UnoNative MplChartElement for Uno Platform (WinUI 3 / Android / iOS / macCatalyst)
MatPlotLibNet.Wpfdotnet add package MatPlotLibNet.WpfNative WPF MplChartControl via SkiaSharp — all 9 interaction modifiers
MatPlotLibNet.Geodotnet add package MatPlotLibNet.Geo13 map projections, GeoJSON parser, Natural Earth 110m data, geographic polygons
MatPlotLibNet.Notebooks#r "nuget: MatPlotLibNet.Notebooks"Inline SVG in Polyglot / Jupyter notebooks. Microsoft has ended Polyglot Notebooks and .NET Interactive, which this package builds on, so existing notebooks keep working but nothing new is coming — for new work use MatPlotLibNet.Interactive
MatPlotLibNet.Mcpdnx MatPlotLibNet.McpMCP server — an AI agent renders charts over stdio (cookbook)
@matplotlibnet/angularnpm install @matplotlibnet/angularAngular components + TypeScript SignalR client
@matplotlibnet/reactnpm install @matplotlibnet/reactReact hooks + components + TypeScript SignalR client
@matplotlibnet/vuenpm install @matplotlibnet/vueVue 3 composables + TypeScript SignalR client

Quick start

csharp
using MatPlotLibNet;
using MatPlotLibNet.Styling;

double[] x = [1, 2, 3, 4, 5];
double[] y = [2, 4, 3, 5, 1];

Plt.Create()
    .WithTitle("My First Chart")
    .WithTheme(Theme.Dark)
    .Plot(x, y, s => { s.Color = Color.Blue; s.Label = "Data"; })
    .WithLegend()
    .Save("chart.svg");

Features

83 series types — line, scatter (plain or coloured by point density), bar (plain, stacked, or several groups per category in one call), histogram, pie, box, violin, heatmap, contour, candlestick, OHLC, treemap, sunburst, Sankey, polar, polar heatmap, 3D surface, Bar3D, PlanarBar3D, Line3D, Trisurf3D, Contour3D, Quiver3D, Voxels, Text3D, radar, waterfall, funnel, gauge, stat tile (single-value KPI), state timeline (discrete state segments over time), pair grid, relative rotation graph, streaming line/scatter/signal/candlestick, and more.

MCP server — charts for an AI agent — MatPlotLibNet.Mcp is a Model Context Protocol server. It ships as a .NET tool that a host starts over stdio. It has five tools: render_chart (returns a PNG plus a text summary of what was drawn), save_chart (writes PNG/SVG/PDF to a file and returns the path it wrote), chart_data_table (returns the numbers the picture is drawn from, as markdown, which an image alone cannot give), list_chart_types and describe_chart_schema. The spec is the library's own figure JSON, so an agent can ask for anything the library draws. When a spec is wrong, the server rejects it before rendering and names the wrong field, instead of returning a blank picture. See the cookbook.

json
{ "servers": { "MatPlotLibNet.Mcp": { "type": "stdio", "command": "dnx", "args": ["MatPlotLibNet.Mcp", "--yes"] } } }

Control room — Plt.OpsDashboard() builds one operator screen: KPI tiles across the top, state timelines under them, a topology panel showing which service calls which (AddTopology), and a shared trend panel. All of them use one time window that the caller supplies; the library never reads the wall clock. A tile carries a Target, a multi-line Caption that wraps, an inline sparkline, and an OpsCondition saying what it is in. That condition has two axes on purpose: OpsSeverity (normal, warning, critical) is the only one that compares, and OpsVisibility (observed, unknown, shelved) says whether the reading can be believed and whether someone silenced it — a silent source is not a degraded one, and a muted alarm is not a solved problem. OpsCondition.RollUp reads a set of children the way an operator does: the worst child that can be seen decides the colour, the unseen and the muted are counted. WithEventMarker puts a deploy or an incident on every panel that has a clock. Theme.Alarm defines the reserved alarm colours, and four operator backgrounds ship with it. BulletGraphSeries replaces the radial gauge.

Native UI controls — MplChartControl for Avalonia 12 and MplChartElement for Uno Platform render charts natively via SkiaSharp. They need no browser, no WebView and no SignalR. There are 9 interaction modifiers: pan (drag), zoom (scroll), 3D rotation (right-drag), rectangle zoom (Ctrl+drag), brush select (Shift+drag), span select (Alt+drag), legend toggle (click), crosshair (passive), hover tooltip. The controls also have a toolbar state model, view history (back/forward), a data cursor (click-to-pin), tick mirroring, and tight margins. Clicking a data point raises DataPointClicked with the point the reader clicked — series, value, pixel position and axes — so an application can open a detail panel or select a row beside the chart. A server-driven chart reports the same click to its OnDataCursor handler.

MathText — LaTeX-like inline math in any label or title: $\alpha^{2}$, $\frac{a}{b}$, $\sqrt{x}$, $\hat{x}$, $\mathbf{F}$, $\mathbb{R}$. It supports 96 symbol mappings (Greek, math operators, arrows, relations, set/logic, blackboard bold), fractions, square roots, accents, font variants, spacing, and scaling delimiters.

International text — labels, titles and legend entries in any script. Arabic and Hebrew work with the bundled font: the Unicode bidi algorithm (UAX #9, all 861,948 conformance cases) finds the reading direction, HarfBuzz shapes each run, and the runs are laid out in visual order. SkiaFonts.Register(path) adds a font file for Devanagari, Thai, Chinese and other scripts; the MCP server takes them from MATPLOTLIBNET_FONTS. The same shaping pass produces the text measurement, the SVG glyph outlines and the PNG pixels.

3-D charts — 12 series types: Surface, Scatter3D, Bar3D, PlanarBar3D, Line3D, Trisurf3D (Delaunay), Contour3D (marching squares), Quiver3D (vector field), Voxels (face-culled cubes), Text3D (annotations). The 3-D support includes a full Projection3D pipeline, a DepthQueue3D painter's algorithm, shading from Vec3.FaceNormal plus the Color.Shade()/Color.Modulate() extension methods, Svg3DRotationScript for client-side rotation with depth re-sorting, camera-derived back faces (CubeFaceSelection: the panes, cube edges, wall grids and tick rows follow the camera at any azimuth, both server-side and during a drag), a configurable Pane3DConfig (floor/wall colors), and 3D colorbar support.

Streaming & Realtime — StreamingLineSeries, StreamingScatterSeries, StreamingSignalSeries and StreamingCandlestickSeries are backed by RingBuffer<T> and add points with AppendPoint(x, y). A RingBuffer<T> is a fixed-capacity circular sequence of any type (64 M appends/s, and it never allocates on append). StreamingFigure provides throttled re-rendering and auto-scaling axes (SlidingWindow, StickyRight, AutoScale). 11 streaming indicators (SMA, EMA, RSI, Bollinger, MACD, OBV, ATR, Stochastic, WilliamsR, CCI, VWAP) attach automatically to candlestick data. Streaming controls exist for Avalonia, Uno, MAUI, Blazor, and ASP.NET Core. The library includes an SVG diff engine to save bandwidth, and an Rx IObservable<T> adapter.

Geographic projections — the MatPlotLibNet.Geo package has 5 map projections (PlateCarree, Mercator, Robinson, Orthographic, LambertConformal), a GeoJSON parser, embedded Natural Earth 110m data, and GeoPolygonSeries for coastlines, borders and choropleths. A symlog axis scale handles data that spans positive and negative ranges.

Bidirectional SignalR — server-authoritative interactive charts with mutation events (zoom, pan, reset, legend toggle) and notification events (brush-select, hover, the clicked data point). The events form a hierarchy of stacked records, they merge on their own, and the server sends each caller its own hover response.

Accessibility — figure.ToDataTables() gives every chart a data table beside the picture (ToHtml(), ToMarkdown(), ToCsv()). That table is the text alternative that WCAG 1.1.1 requires for a complex image, and an <svg role="img"> cannot provide it on its own. The table is served by MapChartTableEndpoint, by MplChart.ShowDataTable, by the GraphQL chartDataTable field and by the MCP chart_data_table tool, which returns it as markdown to read and as structured values to compute with. The library also has ARIA roles and titles, keyboard navigation, the Okabe-Ito colour-blind-safe palette, the three Petroff accessible colour sequences and a high-contrast theme.

148 colormaps — viridis, plasma, turbo, coolwarm, and 144 more (74 base maps, each with an auto-registered reversed _r variant). The library also has NumPy-style SIMD numerics (Vec, Mat, Linalg, Fft), themes that look like matplotlib's, DataFrame integration with 58 technical indicators, broken axes, and publication-quality SVG/PNG/PDF/GIF export.


License

MIT — free for any use, open-source or commercial, with no copyleft conditions.

将 MatPlotLibNet MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 MatPlotLibNet 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 MatPlotLibNet 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 MatPlotLibNet MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "matplotlibnet": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 MatPlotLibNet MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 MatPlotLibNet MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 MatPlotLibNet 帮我完成这项任务吗?
MatPlotLibNet
当然。我已阅读。
以下是我使用 MatPlotLibNet 得到的结果。

常见问题

MatPlotLibNet MCP 服务器有什么用途?

MatPlotLibNet 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 MatPlotLibNet MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 MatPlotLibNet,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 MatPlotLibNet MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 MatPlotLibNet 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 MatPlotLibNet MCP 连接到 TypingMind?

MatPlotLibNet 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

MatPlotLibNet MCP 在 TypingMind 中提供哪些工具?

MatPlotLibNet 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 MatPlotLibNet MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 MatPlotLibNet 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇