是的,ScottPlot 是一個用于創建和顯示科學圖表的 C# 庫。它支持將圖表導出為常見的圖像格式,如 PNG、JPEG 和 BMP。以下是一個簡單的示例,展示了如何使用 ScottPlot 導出圖表為 PNG 圖像:
using ScottPlot;
using System;
using System.Drawing;
class Program
{
static void Main()
{
// 創建一個簡單的圖表
var plt = new Plot(600, 400);
plt.PlotBar(new double[] { 1, 3, 2, 5, 4 }, new double[] { 3, 5, 1, 6, 4 });
// 設置圖表標題和軸標簽
plt.Title("Bar Chart Example");
plt.xlabel("X Axis");
plt.ylabel("Y Axis");
// 導出圖表為 PNG 圖像
string filePath = "chart.png";
plt.SaveFig(filePath);
Console.WriteLine($"Chart saved to {filePath}");
}
}
在這個示例中,我們首先創建了一個簡單的柱狀圖,然后設置了圖表的標題和軸標簽。最后,我們使用 SaveFig
方法將圖表導出為名為 “chart.png” 的 PNG 圖像。