c# - ILSurface 绘图参数

标签 c# 3d matplotlib plot ilnumerics

我坚持在 ILSurface 中绘制曲面。 场景如下:

绘制不规则网格:

float[] x = new float[sizeX]; // filled with timestamps

float[] y = new float[sizeY]; // filled with values

float[,] z = new float[sizeX, sizeY]; // filled with values mapped by [x,y]

ILInArray<float> inX = ILMath.array(x);
ILInArray<float> inY = ILMath.array(y);
ILInArray<float> inZ = ILMath.meshgrid(inX * inY, inX, inY);

// how do i fill the inZ with z[,]?

ILRetArray<float> outMesh = ILMath.meshgrid(inX, inY, inZ, null, null);

plotCube.Add(new ILSurface(outMesh, null, null, null, null));

// plotCube already attached to the scene, and the scene with the ILPanel

ilPanel1.Refresh(); 

想要将其映射到一个数组中,以便可以将其绘制在 ILSurface 上.

我已经尝试了一些 ILMath.meshgrid填写 ILInArray<double> ZXYArray没有成功。

希望我已经说清楚了。欢迎任何帮助。

谢谢。

最佳答案

这是一个简单示例,说明如何使用 ILNumerics 绘制 3D 表面并提供自定义 X 和 Y 范围。它期望使用 ILNumerics 定期设置 Windows.Forms 应用程序:

private void ilPanel1_Load(object sender, EventArgs e) {
    // define X and Y range
    ILArray<float> X = ILMath.vec<float>(-10.0, 0.1, 10.0);
    ILArray<float> Y = ILMath.vec<float>(-6.0, 0.1, 6.0);

    // compute X and Y coordinates for every grid point
    ILArray<float> YMat = 1; // provide YMat as output to meshgrid
    ILArray<float> XMat = ILMath.meshgrid(X, Y, YMat); // only need mesh for 2D function here

    // preallocate data array for ILSurface: X by Y by 3
    // Note the order: 3 matrix slices of X by Y each, for Z,X,Y coordinates of every grid point
    ILArray<float> A = ILMath.zeros<float>(Y.Length, X.Length, 3); 

    // fill in Z values (replace this with your own function / data!!)
    A[":;:;0"] = ILMath.sin(XMat) * ILMath.sin(YMat) * ILMath.exp(-ILMath.abs(XMat * YMat) / 5);
    A[":;:;1"] = XMat; // X coordinates for every grid point
    A[":;:;2"] = YMat; // Y coordinates for every grid point

    // setup the scene + plot cube + surface 
    ilPanel1.Scene = new ILScene() {
        new ILPlotCube(twoDMode: false) {
            new ILSurface(A) {
                UseLighting = true, 
                Children = { new ILColorbar() }
            }
        }
    };
}

它产生以下结果:

ILNumerics Surface Plot

这是同一个例子 as interactive Web Component .

注意定义网格点坐标的顺序。请参阅此处的文档:http://ilnumerics.net/surface-plots.html

关于c# - ILSurface 绘图参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19757693/

相关文章:

c# - C# : generate a list of two dimension arrays with the same shape 中的 FsCheck

c - 在同一个 OpenGL 窗口中绘制 2D 和 3D

math - 改进了 WebGL 和 ThreeJS 中的区域照明

python - Pandas 从相应的唯一 id 值绘制平均值

python - 如何获取 Matplotlib 生成的散点图的像素坐标?

c# - 网络计算机IP地址

c# - 如何在 ColdFusion 中运行 .net 函数

python - 在 matlibplot python 中以对数刻度填充曲线下的区域

c# - 在 WPF 中使用字典进行双向数据绑定(bind)

math - 从给定点垂直于线段