2016-08-05 63 views
0

下面的图是使用MATLAB创建的。我想在windows窗体中使用excact同样的情节。在.NET中以相同的x值绘制几个Y值

enter image description here

但是,它不工作了绘制几个y值到一个x值(在这种情况下:0)。

我的代码

this.chart3.Series["Series1"].Points.Clear(); 
this.chart3.Series["Series1"].Points.AddXY(0, doubleValueArray); //length is 1600 
this.chart3.Update(); 

,但我得到的错误

Exception was thrown: Series data points do not support values of type 
System.Double[] only values of these types can be used: Double, Decimal, 
Single, int, long, uint, ulong, String, DateTime, short, ushort. 

...我不明白,因为根据该documentation的AddXY的第二个参数接受一个双数组。

我是否需要设置其他内容在属性?

感谢所有帮助

+0

只有像BoxPlot这样的几个charttypes才能将y值接受为数组。对于点行类型,每个数据点需要一个x值和一个y值。 – TaW

回答

0

您需要为AddXY功能两个数组:

this.chart3.Series["Series1"].Points.AddXY(xArray, yArray); 

在xArray存在单一数据点的x值。所以在你的情况下,它应该是一个有1600个零的数组。

UPDATE:

您必须添加

this.chart3.Series["Series1"].CustomProperties = "IsXAxisQuantitative=True"; 

否则也不会在x = 0轴

我制定了该轴的问题在自己的问题的工作:Plotting two y-values for x=0 in a MS Chart control

相关问题