在 .NET 中以相同的 x 值绘制多个 Y 值 [英] Plot several Y-values at the same x-value in .NET

查看:48
本文介绍了在 .NET 中以相同的 x 值绘制多个 Y 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下图是使用 MATLAB 创建的.我想在 Windows 窗体中有完全相同的图.

The following plot was created with MATLAB. I want to have the excact same plot in windows forms.

但是,将多个 y 值绘制为一个 x 值(在本例中为 0)是行不通的.

However, it does not work out to plot several y-values to one x-value (in this case: 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.

...我不明白,因为基于 文档 AddXY 的第二个参数接受双数组.

...what I do not understand, because based on the documentation the second parameter of the AddXY accepts an double array.

我是否需要设置其他东西,例如在属性?

Do I need to setup something else e.g. in the properties?

感谢您的帮助

推荐答案

AddXY 函数需要两个数组:

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

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

In xArray there a the x-values of the single data points. So in your case it should be an array with 1600 zeros.

更新:

你必须添加

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

否则它不会在 x=0 轴上工作

otherwise it will not work on the x=0 axis

我在自己的问题中表述了该轴上的问题:在 MS 图表控件中为 x=0 绘制两个 y 值

I formulated the problem on that axis in an own question: Plotting two y-values for x=0 in a MS Chart control

这篇关于在 .NET 中以相同的 x 值绘制多个 Y 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆