[英]There is a line in the bottom part of the graph that joins the last point while using zedgraph. How can I remove this?
這是我的代碼:
我正在嘗試從文件夾中獲取CSV文件。 之后,我從這些文件中獲取數據並將它們存儲在zedX和zedY列表中。 我將這兩個數組傳遞給zedgraphControl。
我正在正確地獲得情節。 但是,有一條直線從0連接到圖形的最后一點。 我應該如何刪除呢?
//I am taking in a folder which have CSV files containing a data. So, iterating over files in the outer loop
for (int i = 0; i < inputFolder.Count; i++)
{
//Lists to contain the data
List<Double> zedXList = new List<double>();
List<Double> zedYList = new List<double>();
//Arrays to be passed into zedgraph
double[] zedX = new double[thisbin.IndLists[i].Count()];
double[] zedY = new double[thisbin.IndLists[i].Count()];
for (int l = 0; l < thisbin.IndLists[i].Count(); l++)
{
zedX[l] = 0;
zedY[l] = 0;
}
//In the inner loop I fetch the data from the file and store it in lists
for (int j = 0; j < thisbin.IndLists[i].Count(); j++)
{
if (j % 2 == 0)
{
zedXList.Add(thisbin.IndLists[i][j]);
}
if (j % 2 != 0)
{
zedYList.Add(thisbin.IndLists[i][j]);
}
}
//from the lists I pass the data into arrays, in order to pass it into zedgraph
for (int k = 0; k < zedXList.Count(); k++)
{
zedX[k] = Convert.ToDouble(zedXList[k]);
zedY[k] = Convert.ToDouble(zedYList[k]);
}
//zedgraph plot
string title = "PLOT-" + Convert.ToString(i + 1);
TabPage myTabPage = new TabPage(title);
var zed = new ZedGraphControl();
zed.Dock = DockStyle.Fill;
zed.Size = new System.Drawing.Size(575, 312);
zed.GraphPane.CurveList.Clear();
var Indpane2 = zed.GraphPane;
Indpane2.Title.Text = "PLOT" + Convert.ToString(i + 1);
Indpane2.XAxis.Title.Text = "m/z";
Indpane2.YAxis.Title.Text = "Intensity";
var ind2 = new PointPairList(zedX, zedY);
var IndCurve2 = Indpane2.AddCurve(title, ind2, Color.OrangeRed, SymbolType.Default);
Indpane2.AxisChange();
myTabPage.Controls.Add(zed);
tabControl1.TabPages.Add(myTabPage);
IndCurve2.Line.IsVisible = true;
IndCurve2.Line.Width = 2.0F;
zed.Invalidate();
zed.Refresh();
}
一個簡單的邏輯錯誤。 zedX和zedY的長度必須僅為thisbin.IndLists長度的一半,因為您可以交替分配值。 因此,其余曲線陣列仍為零,因此曲線的最后點為[0,0]。
因此,您必須這樣做:
double[] zedX = new double[thisbin.IndLists[i].Count()/2];
double[] zedY = new double[thisbin.IndLists[i].Count()/2];
代替這個:
double[] zedX = new double[thisbin.IndLists[i].Count()];
double[] zedY = new double[thisbin.IndLists[i].Count()];`
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.