### Install MatPlotLibNet.AspNetCore Source: https://github.com/xkqg/matplotlibnet/wiki/Package-Map Install the MatPlotLibNet.AspNetCore package for server-side chart infrastructure. ```bash dotnet add package MatPlotLibNet.AspNetCore ``` -------------------------------- ### Install @matplotlibnet/react and @microsoft/signalr Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/matplotlibnet-react/README.md Install the React components and the SignalR client library required for real-time updates. ```bash npm install @matplotlibnet/react @microsoft/signalr ``` -------------------------------- ### Install @matplotlibnet/angular and @microsoft/signalr Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/matplotlibnet-angular/README.md Install the Angular components and the SignalR client package. ```bash npm install @matplotlibnet/angular @microsoft/signalr ``` -------------------------------- ### Install @matplotlibnet/vue and SignalR Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/matplotlibnet-vue/README.md Install the package and its peer dependency using npm. ```bash npm install @matplotlibnet/vue @microsoft/signalr ``` -------------------------------- ### Install MatPlotLibNet.GraphQL package Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.GraphQL/README.md Install the MatPlotLibNet.GraphQL NuGet package into your project. ```bash dotnet add package MatPlotLibNet.GraphQL ``` -------------------------------- ### Install MatPlotLibNet packages Source: https://github.com/xkqg/matplotlibnet/blob/main/docs/cookbook/animation.md Install the required NuGet packages for GIF and PDF export. ```bash dotnet add package MatPlotLibNet dotnet add package MatPlotLibNet.Skia ``` -------------------------------- ### Install MatPlotLibNet.Uno package Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.Uno/README.md Install the MatPlotLibNet.Uno NuGet package into your project. ```bash dotnet add package MatPlotLibNet.Uno ``` -------------------------------- ### Install and use MatPlotLibNet.Uno Source: https://github.com/xkqg/matplotlibnet/wiki/Interactive-Controls Install the Uno Platform package and add the MplChartElement to a view, binding the Figure property and enabling interaction. ```bash dotnet add package MatPlotLibNet.Uno ``` ```xml ``` -------------------------------- ### ASP.NET Core server-push streaming setup Source: https://github.com/xkqg/matplotlibnet/wiki/Streaming ASP.NET Core server-push setup: registers SignalR services, creates a StreamingFigure, and registers it under a key. The RenderRequested event automatically publishes SVG to all connected clients. ```csharp services.AddMatPlotLibNetSignalR(); // In a background service: var sf = new StreamingFigure(figure); registry.RegisterStreaming("dashboard-1", sf); // sf.RenderRequested auto-publishes SVG to all connected clients ``` -------------------------------- ### Install MatPlotLibNet.Interactive package Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.Interactive/README.md Installs the MatPlotLibNet.Interactive package into the project. ```bash dotnet add package MatPlotLibNet.Interactive ``` -------------------------------- ### Server setup with AddMatPlotLibNetSignalR and MapChartHub Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/matplotlibnet-react/README.md Server-side setup for a MatPlotLibNet.AspNetCore backend. Registers SignalR services, maps the ChartHub, and maps an endpoint that returns the chart SVG. ```csharp builder.Services.AddMatPlotLibNetSignalR(); app.MapChartHub(); app.MapChartSvgEndpoint("/api/chart.svg", ctx => BuildChart()); ``` -------------------------------- ### Bidirectional SignalR interaction quick start Source: https://github.com/xkqg/matplotlibnet/wiki/Package-Map Bidirectional interaction quick start (v1.2.2): creates a figure with all six interaction events, registers it with a FigureRegistry, and attaches brush-select and hover handlers via ChartSessionOptions. The OnBrushSelect handler is fire-and-forget; OnHover returns tooltip HTML to the originating client only. ```csharp var figure = Plt.Create() .Plot(xs, ys) .WithServerInteraction("live-1", i => i.All()) // all six events: Zoom, Pan, Reset, LegendToggle, BrushSelect, Hover .Build(); var registry = app.Services.GetRequiredService(); registry.Register("live-1", figure, opts => opts .OnBrushSelect(evt => { Console.WriteLine($"Selected [{evt.X1}..{evt.X2}] × [{evt.Y1}..{evt.Y2}]"); return default; }) .OnHover(async evt => $"{await LookupValueAtAsync(evt.X, evt.Y):F2}")); ``` -------------------------------- ### ASP.NET Core SignalR server setup and publish Source: https://github.com/xkqg/matplotlibnet/wiki/Advanced Registers SignalR services and shows how to push SVG updates from anywhere in the app using publisher.PublishSvgAsync. ```csharp builder.Services.AddMatPlotLibNetSignalR(); // Push update anywhere in your app await publisher.PublishSvgAsync("sensor-1", figure); ``` -------------------------------- ### Install and use MatPlotLibNet.Avalonia Source: https://github.com/xkqg/matplotlibnet/wiki/Interactive-Controls Install the Avalonia package and add the MplChartControl to a view, binding the Figure property and enabling interaction. ```bash dotnet add package MatPlotLibNet.Avalonia ``` ```xml ``` -------------------------------- ### Install MatPlotLibNet.Maui package Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.Maui/README.md Install the MatPlotLibNet.Maui NuGet package into a .NET MAUI project. ```bash dotnet add package MatPlotLibNet.Maui ``` -------------------------------- ### Install MatPlotLibNet.Blazor package Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.Blazor/README.md Adds the MatPlotLibNet.Blazor NuGet package to the project. ```bash dotnet add package MatPlotLibNet.Blazor ``` -------------------------------- ### Install MatPlotLibNet.Skia package Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.Skia/README.md Adds the MatPlotLibNet.Skia NuGet package to the project. ```bash dotnet add package MatPlotLibNet.Skia ``` -------------------------------- ### Theme API Examples Source: https://github.com/xkqg/matplotlibnet/blob/main/docs/cookbook/themes.md Code snippets demonstrating theme creation and usage in MatplotlibNet. ```APIDOC ## [Theme.CreateFrom] Theme with 3D pane colors ### Description Creates a custom theme based on an existing theme (e.g., Theme.Dark) and applies it to a plot with 3D pane colors. ### Method Theme.CreateFrom ### Parameters - **base** (Theme) - Required - The base theme to start from. ### Request Example ```csharp var theme3d = Theme.CreateFrom(Theme.Dark) .WithBackground(Color.FromHex("#1a1a2e")) .WithForegroundText(Colors.White) .Build(); ``` ### Response Returns a Theme object that can be used with Plt.Create().WithTheme(). ``` ```APIDOC ## [Plt.Create().WithBackground] Theme background shortcut ### Description Quickly sets the figure background color and applies a theme (e.g., Theme.Paper) to a plot. ### Method Plt.Create().WithBackground ### Parameters - **color** (Color) - Required - The background color to apply. ### Request Example ```csharp Plt.Create() .WithBackground(Color.FromHex("#f5f5dc")) // beige .WithTheme(Theme.Paper) .Plot(x, y) .Save("paper_bg.svg"); ``` ### Response Returns a plot object that can be saved. ``` ```APIDOC ## [ThemeBuilder] Fluent API reference ### Description Reference for the fluent API methods available on ThemeBuilder and related objects. ### Methods - **WithTheme(Theme preset)** - Apply a built-in or custom theme. - **WithBackground(Color)** - Override figure background. - **Theme.CreateFrom(base)** - Start a ThemeBuilder from existing theme. - **WithForegroundText(Color)** - Text/foreground color. - **WithAxesBackground(Color)** - Axes area background. - **WithCycleColors(params Color[])** - Color cycle for series. - **WithFont(Func)** - Default font (family, size, weight). - **WithGrid(Func)** - Grid appearance. - **WithPropCycler(PropCycler)** - Multi-property cycler. - **Build()** - Return customized Theme. ``` -------------------------------- ### Install JavaScript clients with npm Source: https://github.com/xkqg/matplotlibnet/wiki/Getting-Started Install the JavaScript client packages for Angular, React, or Vue 3 using npm. These are for TypeScript and SignalR clients. ```bash npm install @matplotlibnet/angular # Angular ``` ```bash npm install @matplotlibnet/react # React ``` ```bash npm install @matplotlibnet/vue # Vue 3 ``` -------------------------------- ### Install MatPlotLibNet.Avalonia package Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.Avalonia/README.md Adds the MatPlotLibNet.Avalonia NuGet package to the project. ```bash dotnet add package MatPlotLibNet.Avalonia ``` -------------------------------- ### Plt.Create() Source: https://github.com/xkqg/matplotlibnet/wiki/Fluent-Cheatsheet Entry point for the fluent API. Returns a FigureBuilder to start chaining. ```APIDOC ## Plt.Create() ### Description Starts fluent construction of a figure. Returns a FigureBuilder for chaining figure-level methods. ### Method Create ### Endpoint Plt.Create() ### Parameters None ### Returns FigureBuilder ### Example ```csharp var builder = Plt.Create(); ``` ``` -------------------------------- ### Run ASP.NET Core sample Source: https://github.com/xkqg/matplotlibnet/wiki/Bidirectional-SignalR Runs the ASP.NET Core sample project and prints the expected local URL. ```bash dotnet run --project Samples/MatPlotLibNet.Samples.AspNetCore # → http://localhost:5000 ``` -------------------------------- ### Dashboard data table output example Source: https://github.com/xkqg/matplotlibnet/wiki/Accessibility Shows the Markdown output of a dashboard data table for a federation view, including a tile row with label, value, target, caption, and trend columns, and a state timeline with start and end times. The table demonstrates how date axis values are printed with precision. ```markdown **Synapse — federation** | label | value | target | caption | trend | | --- | --- | --- | --- | --- | | Buses | 15 | | all 15 normal | | | RFx p99 | 28.1 | 25 | target 25 ms · +3.1 | 24.1, 24.8, 25.3, 26… | **Synapse — federation — Exchange feed** | state | start | end | | --- | --- | --- | | normal | 2026-09-12 07:55 | 2026-09-12 07:57 | | degraded | 2026-09-12 07:57 | 2026-09-12 07:58:20 | ``` -------------------------------- ### Expose SignalR HubConnection for SVG interaction Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.AspNetCore/README.md Host page setup for the frontend hookup: loads the SignalR client, creates a HubConnection to '/charts-hub', exposes it globally as window.__mpl_signalr_connection, subscribes to 'UpdateChartSvg' for chart 'live-1', and starts the connection. The SVG's embedded script uses this connection when the first event fires. ```html ``` -------------------------------- ### Build the project Source: https://github.com/xkqg/matplotlibnet/blob/main/CONTRIBUTING.md Build the solution using the .NET 10 SDK. ```bash dotnet build ``` -------------------------------- ### Run the Console sample generator Source: https://github.com/xkqg/matplotlibnet/blob/main/Samples/README.md Runs the console app that creates every sample image shipped with the wiki and cookbook: 74 SVG/PNG pairs covering every chart family, plus the package icon and the documentation site's 1200x630 link preview card. Output goes to the images/ directory at the repository root. Re-run it whenever a rendering change would alter committed sample output. ```bash dotnet run --project MatPlotLibNet.Samples.Console ``` -------------------------------- ### Create chart with Arabic and Hebrew labels in C# Source: https://github.com/xkqg/matplotlibnet/blob/main/docs/cookbook/international-text.md Creates a chart with Arabic and Hebrew labels using the default DejaVu Sans font. No extra setup is needed for these scripts; the library applies the bidi algorithm and HarfBuzz shaping automatically. The example sets an Arabic title, a Hebrew legend entry, and saves the result as an SVG. ```csharp Plt.Create() .WithTitle("درجة الحرارة") // Arabic title: "temperature" .AddSubPlot(1, 1, 1, ax => { ax.SetXLabel("Quarter"); ax.SetYLabel("°C"); ax.Plot([1, 2, 3, 4], [12.5, 14.0, 13.2, 15.1], s => s.Label = "תל אביב"); // Hebrew legend entry ax.Plot([1, 2, 3, 4], [9.8, 11.2, 10.5, 12.0], s => s.Label = "Amsterdam"); ax.WithLegend(); }) .Save("international.svg"); ``` -------------------------------- ### Run Web API sample Source: https://github.com/xkqg/matplotlibnet/blob/main/Samples/README.md Run the ASP.NET Core minimal API sample project. Provides REST endpoints for charts and a SignalR hub for live updates. ```bash dotnet run --project MatPlotLibNet.Samples.WebApi ``` -------------------------------- ### Run the Playground sample Source: https://github.com/xkqg/matplotlibnet/blob/main/Samples/README.md Runs the Blazor WebAssembly interactive explorer with 16 example charts. After running, browse to http://localhost:5000. The setting in wwwroot/index.html is auto-detected for localhost; the GitHub Pages deploy uses the /MatPlotLibNet/playground/ subpath. ```bash dotnet run --project MatPlotLibNet.Playground ``` -------------------------------- ### Run GraphQL sample Source: https://github.com/xkqg/matplotlibnet/blob/main/Samples/README.md Run the HotChocolate GraphQL server sample project. Provides queries and subscriptions for chart data. ```bash dotnet run --project MatPlotLibNet.Samples.GraphQL ``` -------------------------------- ### Run Control Room sample app Source: https://github.com/xkqg/matplotlibnet/blob/main/Samples/README.md Run the Control Room reference implementation. It simulates a 15-bus federation on Plt.OpsDashboard() and demonstrates a complete screen with navigation, alarms, and KPI tiles. ```bash dotnet run --project MatPlotLibNet.Samples.ControlRoom ``` -------------------------------- ### Run Blazor sample app Source: https://github.com/xkqg/matplotlibnet/blob/main/Samples/README.md Run the Blazor Server sample app. It serves static charts at the root path and a real-time chart at /live that updates every 3 seconds via SignalR. ```bash dotnet run --project MatPlotLibNet.Samples.Blazor ``` -------------------------------- ### OpsDashboard fluent builder example Source: https://github.com/xkqg/matplotlibnet/blob/main/docs/contrib/history/v1-14-control-room-pack.md Shows the fluent API for building an OpsDashboard with a shared time window, tiles, timelines, trends, and a normal band. WithWindow pins the time axis for all time panels, ensuring they slide in lock-step. ```csharp Plt.OpsDashboard() .WithTitle("Synapse — federation") .WithWindow(DateTime.UtcNow, TimeSpan.FromMinutes(5)) // pinned rolling clock, shared by EVERY time panel .AddTile(15, t => { t.Label = "Buses"; t.Caption = "all 15 normal"; }) .AddTile(24.8, t => { t.Label = "RFx p99"; t.Target = 25; t.Trend = p99; t.Format = "0.0' ms'"; }) .AddTimeline(busSegments, s => s.Label = "Service Bus") .AddTrend(x, publish, s => s.Label = "publish") .AddTrend(x, consume, s => s.Label = "consume") .WithNormalBand(2200, 2700) .Build(); ``` -------------------------------- ### Build an OpsDashboard with window, event marker, tile, timeline, and trend Source: https://github.com/xkqg/matplotlibnet/blob/main/docs/cookbook/dashboard.md Shows how to configure an OpsDashboard with a time window, an event marker, a tile, a timeline, and a trend. The event marker is applied to panels with a time axis. ```csharp Plt.OpsDashboard() .WithWindow(now, TimeSpan.FromMinutes(30)) .WithEventMarker(deployedAt, m => m.Label = "deploy 1.4.2") .AddTile(errors, t => t.Label = "Errors") .AddTimeline(segments) .AddTrend(clock, latency) .Build(); ``` -------------------------------- ### Run the ControlRoom sample project Source: https://github.com/xkqg/matplotlibnet/wiki/Chart-Types Command to run the ControlRoom sample project from the repository root. This is a separate sample project that simulates a 15-bus federation with a background simulator. ```bash dotnet run --project Samples/MatPlotLibNet.Samples.ControlRoom ``` -------------------------------- ### Install MatPlotLibNet.DataFrame package Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.DataFrame/README.md Install the MatPlotLibNet.DataFrame NuGet package to enable DataFrame extension methods for plotting. ```bash dotnet add package MatPlotLibNet.DataFrame ``` -------------------------------- ### Run WPF sample with MplChartControl Source: https://github.com/xkqg/matplotlibnet/blob/main/Samples/README.md Command to run the WPF sample project. Uses MatPlotLibNet.Wpf and demonstrates swapping the bound Figure at runtime via chart-type buttons and toggling IsInteractive. ```bash dotnet run --project MatPlotLibNet.Samples.Wpf ``` -------------------------------- ### Install MatPlotLibNet with dotnet add package Source: https://github.com/xkqg/matplotlibnet/wiki/Home Install the MatPlotLibNet package via the .NET CLI. This is the standard way to add the library to a project. ```bash dotnet add package MatPlotLibNet ``` -------------------------------- ### Bump / Rank Chart Example Source: https://github.com/xkqg/matplotlibnet/blob/main/docs/cookbook/line-charts.md Example of creating a bump chart (rank chart) using the fluent API, including inverting the Y axis and plotting multiple series. ```APIDOC ## Bump / Rank Chart Example ### Description Creates a bump chart (rank chart) by inverting the Y axis so rank 1 is at the top. Uses `SetYLim(n + 0.5, 0.5)` to flip the scale. ### Code Example ```csharp var rng = new Random(99); string[] brands = ["Alpha", "Beta", "Gamma", "Delta", "Epsilon"]; int periods = 8; double[] xPeriods = Enumerable.Range(1, periods).Select(i => (double)i).ToArray(); var palette = new[] { "#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00" }; int[][] ranks = Enumerable.Range(0, brands.Length).Select(_ => new int[periods]).ToArray(); for (int p = 0; p < periods; p++) { int[] perm = Enumerable.Range(1, brands.Length).OrderBy(_ => rng.Next()).ToArray(); for (int b = 0; b < brands.Length; b++) ranks[b][p] = perm[b]; } Plt.Create() .WithTitle("Bump Chart — Brand Ranking over Time") .WithSize(900, 450) .AddSubPlot(1, 1, 1, ax => { for (int b = 0; b < brands.Length; b++) { double[] y = ranks[b].Select(r => (double)r).ToArray(); ax.Plot(xPeriods, y, s => { s.Color = Color.FromHex(palette[b]); s.LineWidth = 3; s.Marker = MarkerStyle.Circle; s.MarkerSize = 10; s.Label = brands[b]; }); } ax.SetYLim(brands.Length + 0.5, 0.5); // invert: rank 1 at top ax.SetYLabel("Rank"); ax.WithLegend(); }) .Save("bump_chart.svg"); ``` ``` -------------------------------- ### Relative Rotation Graph (RRG) with and without overlays Source: https://github.com/xkqg/matplotlibnet/wiki/Chart-Types Two RelativeRotation examples: a basic one plotting three alts against a BTC benchmark with a fading tail, and one with AbsorptionRatioPerBar and EnbPerBar overlays. The basic example uses TailLength = 12 and ColorMaps.Plasma. The overlay example expects double[] arrays for absorption (0..1, green→red fill) and ENB (radius proportional to ENB). ```csharp // Basic — three alts vs BTC benchmark Plt.Create() .AddSubPlot(1, 1, 1, ax => ax .SetXLabel("RS-Ratio") .SetYLabel("RS-Momentum") .RelativeRotation( new[] { ethCloses, bnbCloses, solCloses }, btcCloses, new[] { "ETH", "BNB", "SOL" }, s => { s.TailLength = 12; s.ColorMap = ColorMaps.Plasma; })) .ToSvg(); ``` ```csharp // With absorption + ENB overlays (Layer 3 → Layer 2 feedback) Plt.Create() .AddSubPlot(1, 1, 1, ax => ax .RelativeRotation(assetCloses, bench, labels, s => { s.AbsorptionRatioPerBar = absorptionPerBar; // double[] [0..1], green→red fill s.EnbPerBar = enbPerBar; // double[], radius ∝ ENB })) .ToSvg(); ``` -------------------------------- ### Run Uno sample on Skia renderer Source: https://github.com/xkqg/matplotlibnet/blob/main/Samples/README.md Command to run the Uno Platform sample. Uses MatPlotLibNet.Uno and requires a Skia head; a WinUI head fails with a type universe error. ```bash dotnet run --project MatPlotLibNet.Samples.Uno ``` -------------------------------- ### Run ASP.NET Core sample with SignalR Source: https://github.com/xkqg/matplotlibnet/blob/main/Samples/README.md Command to run the ASP.NET Core sample. Uses a figure registry and SignalR hub to stream SVG updates to clients, with WithServerInteraction() for pan/zoom/reset/legend-toggle. ```bash dotnet run --project MatPlotLibNet.Samples.AspNetCore ``` -------------------------------- ### Live line chart with StreamingLineSeries Source: https://github.com/xkqg/matplotlibnet/blob/main/docs/cookbook/streaming.md Create a live line chart that appends data points from any thread and auto-updates at the configured frame rate (30fps here). The chart is built with a capacity of 5000 points and a blue series labeled "Sensor A". Dispose the StreamingFigure when done. ```csharp StreamingLineSeries? series = null; var sf = Plt.Create() .WithTitle("Live Telemetry") .AddSubPlot(1, 1, 1, ax => { series = ax.StreamingPlot(capacity: 5000, configure: s => { s.Color = Colors.Blue; s.Label = "Sensor A"; }); }) .BuildStreaming(TimeSpan.FromMilliseconds(33)); // 30fps // Append from data source (any thread) for (int i = 0; i < 1000; i++) { series!.AppendPoint(i, Math.Sin(i * 0.1) + Random.Shared.NextDouble() * 0.5); await Task.Delay(10); } sf.Dispose(); ``` -------------------------------- ### Chart spec JSON example Source: https://github.com/xkqg/matplotlibnet/blob/main/Src/MatPlotLibNet.Mcp/README.md Example chart spec in the library's own figure JSON format, the same document that figure.ToJson() writes and ChartSerializer.FromJson reads. The server validates this spec before rendering and rejects unknown fields, chart types, misspelled enum values, unknown colours, or missing sizes. ```json { "width": 800, "height": 600, "title": "Revenue", "subPlots": [{ "series": [{ "type": "line", "xData": [1, 2, 3, 4, 5], "yData": [2, 4, 3, 5, 1], "label": "Q1" }] }] } ``` -------------------------------- ### GET /charts/{id}.svg Source: https://github.com/xkqg/matplotlibnet/wiki/Package-Map REST endpoint that serves the SVG representation of a chart by its identifier. ```APIDOC ## [GET] /charts/{id}.svg ### Description Retrieves the SVG representation of a chart by its identifier. ### Method GET ### Endpoint /charts/{id}.svg ### Parameters #### Path Parameters - **id** (string) - Required - The chart identifier. ### Response #### Success Response (200) - **body** (string) - The SVG content of the chart. #### Response Example ... ``` -------------------------------- ### Run benchmark suites with dotnet run Source: https://github.com/xkqg/matplotlibnet/wiki/Benchmarks Commands to run the benchmark suites. Run one suite at a time to avoid CPU contention that inflates timings. ```bash cd Benchmarks/MatPlotLibNet.Benchmarks dotnet run -c Release -- --filter "*SvgRendering*" dotnet run -c Release -- --filter "*Indicator*" dotnet run -c Release -- --filter "*" # all suites ``` -------------------------------- ### Reference MatPlotLibNet.Notebooks in a notebook Source: https://github.com/xkqg/matplotlibnet/wiki/Notebooks References the MatPlotLibNet.Notebooks package in a Polyglot Notebook. This is the existing setup that continues to work as before. ```csharp #r "nuget: MatPlotLibNet.Notebooks" ``` -------------------------------- ### Project structure overview Source: https://github.com/xkqg/matplotlibnet/wiki/Contributing Directory layout showing the source, test, samples, and benchmarks folders. Every Src/X folder has a matching Tst/X folder. ```text Src/ Source projects (one folder per package) MatPlotLibNet/ Core — models, fluent API, SVG renderer, JSON MatPlotLibNet.Skia/ PNG/PDF/GIF export MatPlotLibNet.Blazor/ ... Tst/ Test projects — mirrors Src/ layout exactly MatPlotLibNet/ MatPlotLibNet.Skia/ ... Samples/ Runnable example projects Benchmarks/ BenchmarkDotNet performance suite ``` -------------------------------- ### Apply a theme with WithTheme Source: https://github.com/xkqg/matplotlibnet/blob/main/docs/cookbook/themes.md Applies a built-in theme to a chart. The example uses Theme.Dracula and saves the result as an SVG file. ```csharp Plt.Create() .WithTheme(Theme.Dracula) .Plot(x, y, s => s.Label = "Data") .WithLegend() .Save("dracula.svg"); ``` -------------------------------- ### Shade below threshold with Threshold Source: https://github.com/xkqg/matplotlibnet/blob/main/docs/cookbook/annotations.md Uses Threshold to shade everything below a value. This example shades below 30 to mark an oversold zone. ```csharp Plt.Create() .AddSubPlot(1, 1, 1, ax => ax .Plot(x, y, s => s.Label = "Signal") .Threshold(30.0, Orientation.Horizontal, ThresholdBreach.Below, color: Colors.Tab10Green, label: "Oversold") .WithLegend()) .Save("threshold_below.svg"); ``` -------------------------------- ### Quick Example: Create and Save a Chart with Plt.Create() Source: https://github.com/xkqg/matplotlibnet/wiki/MatPlotLibNet Creates a chart with a title, dark theme, a blue line series labeled "Data", a legend, and saves it as an SVG file. Uses the fluent builder API where Save() calls Build() internally. ```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"); ``` -------------------------------- ### Configure pie series properties Source: https://github.com/xkqg/matplotlibnet/wiki/Fluent-Cheatsheet Sets explode offsets, percentage label format, start angle, and shadow for a pie chart. ```csharp // Pie ax.Pie(sizes, labels, s => { s.Explode = [0, 0.1, 0, 0]; s.AutoPct = "{0:F1}%"; s.StartAngle = 90; s.Shadow = true; }); ``` -------------------------------- ### Run tests Source: https://github.com/xkqg/matplotlibnet/blob/main/CONTRIBUTING.md Run the test suite. ```bash dotnet test ``` -------------------------------- ### MatPlotLibNet.Geo Usage Examples Source: https://github.com/xkqg/matplotlibnet/wiki/Chart-Types Code snippets for the MatPlotLibNet.Geo package: creating a world map, rendering choropleth polygons, and using the IGeoProjection interface. ```APIDOC ## [C#] MatPlotLibNet.Geo - Create a World Map with Mercator Projection ### Description Creates a world map using the Mercator projection, adding ocean, land, coastlines, and borders. ### Method C# method chain: `Plt.Create().AddSubPlot(...).Save(...)` ### Endpoint Not applicable (SDK method chain) ### Parameters #### Method Parameters - `subplotCount` (int) - Required - Number of subplots (1, 1, 1) - `ax` (Action) - Required - Lambda to configure the axes #### Axes Extension Methods - `WithProjection(IGeoProjection)` - Required - Sets the projection (e.g., `new Mercator()`) - `Ocean(projection, color)` - Optional - Fills the ocean with a color - `Land(projection, color)` - Optional - Fills land masses with a color - `Coastlines(projection, color, lineWidth)` - Optional - Adds coastlines - `Borders(projection, color, lineWidth)` - Optional - Adds country borders ### Request Example ```csharp using MatPlotLibNet.Geo.Projections; Plt.Create() .AddSubPlot(1, 1, 1, ax => ax .WithProjection(new Mercator()) .Ocean(new Mercator(), new Color(180, 220, 255)) .Land(new Mercator(), new Color(240, 230, 200)) .Coastlines(new Mercator(), Colors.Black, lineWidth: 0.5) .Borders(new Mercator(), Colors.Gray, lineWidth: 0.3)) .Save("worldmap.svg"); ``` ### Response #### Success Response - Saves the plot to the specified file (e.g., `worldmap.svg`). #### Response Example Not applicable (file output). ``` ```APIDOC ## [C#] GeoPolygonSeries - Render a Choropleth Map ### Description Renders a choropleth map by adding `GeoPolygonSeries` for each country, colored by a metric. ### Method C# method: `ax.AddSeries(new GeoPolygonSeries(poly, projection) { ... })` ### Endpoint Not applicable (SDK method) ### Parameters #### Constructor Parameters - `poly` (GeoJSON feature) - Required - The polygon geometry (e.g., from `NaturalEarth110m.Countries`) - `projection` (IGeoProjection) - Required - The map projection (e.g., `new Robinson()`) #### Properties - `FillColor` (Color) - Optional - Fill color for the polygon - `EdgeColor` (Color) - Optional - Edge color - `EdgeWidth` (double) - Optional - Edge width ### Request Example ```csharp var ax = Plt.Create() .AddSubPlot(1, 1, 1, ax => ax.WithProjection(new Robinson())); foreach (var (country, value) in countryData) { var poly = NaturalEarth110m.Countries.First(c => c.Properties["NAME"] == country); ax.AddSeries(new GeoPolygonSeries(poly, new Robinson()) { FillColor = ColorMaps.Viridis.GetColor(value / maxValue), EdgeColor = Colors.White, EdgeWidth = 0.3, }); } ``` ### Response #### Success Response - Adds the series to the axes for rendering. #### Response Example Not applicable (in-memory operation). ``` ```APIDOC ## [C#] IGeoProjection - Forward and Inverse Transformations ### Description Defines the interface for map projections, providing forward and inverse coordinate transformations. ### Method Interface methods: `Forward(latitude, longitude)` and `Inverse(x, y)` ### Endpoint Not applicable (interface) ### Parameters #### Forward Parameters - `latitude` (double) - Required - Latitude in degrees - `longitude` (double) - Required - Longitude in degrees #### Inverse Parameters - `x` (double) - Required - X coordinate in projected space - `y` (double) - Required - Y coordinate in projected space ### Request Example ```csharp IGeoProjection proj = new Mercator(); ProjectedPoint p = proj.Forward(45.0, -120.0); GeoCoordinate? coord = proj.Inverse(p.X, p.Y); ``` ### Response #### Success Response - `Forward` returns `ProjectedPoint` (record struct with `X` and `Y`). - `Inverse` returns `GeoCoordinate?` (nullable record struct with `Latitude` and `Longitude`). #### Response Example ```csharp ProjectedPoint p = new ProjectedPoint(123.45, 67.89); GeoCoordinate coord = new GeoCoordinate(45.0, -120.0); ``` ```