2015-06-19 107 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值在同一平面上。