繁体   English   中英

使用zedgraph时,图形的底部有一条线连接最后一点。 我该如何删除?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM