2

这是我用来绘制离散图的代码:

private void DrawHartleyGraph(double [] values, ZedGraphControl zed)
        {
            GraphPane pane = zed.GraphPane;
            pane.CurveList.Clear();
            pane.XAxis.Title.Text = "ν";
            pane.YAxis.Title.Text = "H(ν)";
            pane.Title.Text = "ДПХ";
            PointPairList list = new PointPairList();
            for (int i = 0; i < values.Length ; i++)
            {
                list.Add((double)i, values[i]);
            }
            LineItem myCurve = pane.AddCurve("H(ν) - ДПХ", list, Color.Blue, SymbolType.Circle);
            myCurve.Line.IsVisible = false;
            myCurve.Symbol.Fill.Color = Color.Blue;
            myCurve.Symbol.Fill.Type = FillType.Solid;
            myCurve.Symbol.Size = 4;
            pane.XAxis.Scale.Min = 0;
            pane.XAxis.Scale.Max = numOfCountsN;
            pane.YAxis.Scale.Min = values.Min();
            pane.YAxis.Scale.Max = values.Max();
            pane.IsBoundedRanges = true;
            zed.AxisChange();
            zed.Invalidate();
        }

我有这样的图片: 离散图

如何绘制从 X 轴开始到点结束的垂直线,表示函数的值?


解决了

这是找到的决定。您需要以这种方式修改for循环:

for (int i = 0; i < values.Length ; i++)
{
    list.Add((double)i, values[i]);
    LineObj vertLine = new LineObj(Color.Red, i, 0,
          i, values[i]);
    pane.GraphObjList.Add(vertLine);
}
4

0 回答 0