2015-06-19 168 views
1

我想从活的x-y坐标数据(使用OxyPlot)制作等高线图。OxyPlot轮廓系列

我见过使用ContourSeries给出的例子,并且我无法理解如何实现轮廓。

下面是示例代码:

namespace ExampleLibrary 
{ 
using System; 

using OxyPlot; 
using OxyPlot.Axes; 
using OxyPlot.Series; 

[Examples("ContourSeries"), Tags("Series")] 
public class ContourSeriesExamples 
{ 
    private static Func<double, double, double> peaks = (x, y) => 
      3 * (1 - x) * (1 - x) * Math.Exp(-(x * x) - (y + 1) * (y + 1)) 
      - 10 * (x/5 - x * x * x - y * y * y * y * y) * Math.Exp(-x * x - y * y) 
      - 1.0/3 * Math.Exp(-(x + 1) * (x + 1) - y * y); 

    [Example("Peaks")] 
    public static PlotModel Peaks() 
    { 
     var model = new PlotModel { Title = "Peaks" }; 
     var cs = new ContourSeries 
      { 
       ColumnCoordinates = ArrayBuilder.CreateVector(-3, 3, 0.05), 
       RowCoordinates = ArrayBuilder.CreateVector(-3.1, 3.1, 0.05) 
      }; 
     cs.Data = ArrayBuilder.Evaluate(peaks, cs.ColumnCoordinates, cs.RowCoordinates); 
     model.Subtitle = cs.Data.GetLength(0) + "×" + cs.Data.GetLength(1); 
     model.Series.Add(cs); 
     return model; 
    } 
} 

有些事情我不明白是“峰”数学方程式(什么是它的目的,它是如何得出的?) 另一件事我不明白轮廓本身是如何派生的。

回答

0

要理解“高峰”,您需要熟悉一般代表Func<T, TResult>。在你的例子中,生成委托“峰值”有两个double输入,一个输出结果也是double。输入假设x和y。 输出是lambda“=>”后的函数。

关于第二个问题;轮廓本身是如何派生的? 可以将轮廓想象为在普通XY笛卡尔上绘制的3D对象,在每个x,y处都有一个z值在同一平面上。