寻峰算法的代码可以在我的上篇博客中查看C#中读取.mat文件,然后实现寻峰算法
核心代码是这部分
LineItem line = zedGraphControl1.GraphPane.AddCurve("", list1, Color.Red, SymbolType.None);//绘制图表
line.Line.Width = 2;
for(int n=0;n< index.Length;n++)
{
PointPair PT = line.Points[index[n]];
string label = data2[n].ToString("f2");
TextObj text = new TextObj(label, PT.X, PT.Y + 5, CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
// 隐藏标注的边框和填充
text.FontSpec.Border.IsVisible = false;
text.FontSpec.FontColor= System.Drawing.Color.Red;//设置字体颜色
text.FontSpec.Fill.IsVisible = false;
text.FontSpec.Fill.Color = System.Drawing.Color.White;
text.FontSpec.Size = 18;//控制标签显示大小
// 选择标注字体90°
text.FontSpec.Angle = 90;//横向显示
zedGraphControl1.GraphPane.GraphObjList.Add(text);
}
效果如下: