尋峯算法的代碼可以在我的上篇博客中查看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);
}
效果如下: