绘图仪:图像
 

图像快速启动

图像绘图仪将位图放置在X/Y空间的某个位置。随着轴的移动,图像的位置将在空间中移动,但位图的大小将始终相同(与显示分辨率匹配)。

var plt = new ScottPlot.Plot(600, 400);

// display some sample data
plt.AddSignal(DataGen.Sin(51));
plt.AddSignal(DataGen.Cos(51));

// create the bitmap we want to display
Bitmap monaLisa = DataGen.SampleImage();

// create the image plottable and add it to the plot
var imagePlot = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 10, Y = .5 };

plt.Add(imagePlot);

plt.SaveFig("image_quickstart.png");
 

图像对齐

默认情况下,X/Y坐标定义图像的左上位置,但可以自定义对齐方式。

var plt = new ScottPlot.Plot(600, 400);

// display some sample data
plt.AddSignal(DataGen.Sin(51));
plt.AddSignal(DataGen.Cos(51));

// display an image with 3 different alignments
Bitmap monaLisa = DataGen.SampleImage();
var ip1 = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 10 };
var ip2 = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 25, Alignment = Alignment.MiddleCenter };
var ip3 = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 40, Alignment = Alignment.LowerRight };

plt.Add(ip1);
plt.Add(ip2);
plt.Add(ip3);

plt.AddPoint(ip1.X, ip1.Y, Color.Magenta, size: 20);
plt.AddPoint(ip2.X, ip2.Y, Color.Magenta, size: 20);
plt.AddPoint(ip3.X, ip3.Y, Color.Magenta, size: 20);

plt.SaveFig("image_alignment.png");
 

图像旋转

图像可以旋转,但旋转始终相对于左上角。

var plt = new ScottPlot.Plot(600, 400);

// display some sample data
plt.AddSignal(DataGen.Sin(51));
plt.AddSignal(DataGen.Cos(51));

// place a rotated image on the plot
Bitmap monaLisa = DataGen.SampleImage();
var ip1 = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 10, Y = .5, Rotation = 30 };
plt.Add(ip1);
plt.AddPoint(ip1.X, ip1.Y, color: Color.Magenta, size: 20);

plt.SaveFig("image_rotation.png");
 

图像边框

图像的边框可以定制。

var plt = new ScottPlot.Plot(600, 400);

// display some sample data
plt.AddSignal(DataGen.Sin(51));
plt.AddSignal(DataGen.Cos(51));

// place an image on the plot
plt.Add(new ScottPlot.Plottable.Image()
{
    Bitmap = DataGen.SampleImage(),
    X = 10,
    Y = .5,
    Rotation = 30,
    BorderColor = Color.Magenta,
    BorderSize = 5,
});

plt.SaveFig("image_border.png");