簡體   English   中英

如何使用Oxyplot創建和繪制ContourSeries?

[英]How do I create and plot a ContourSeries with Oxyplot?

我有一個WPF應用程序,需要可視化y = y(x1,x2),其中x1,x2是線性坐標。 我可以使用Oxyplot中的HeatMapSeries進行此操作,但是當我想在同一窗口中繪制兩組數據時,熱圖不是合適的工具。 幾個輪廓系列會更好。 現在,我試圖以與HeatMapSeries相同的方式實現這一目標,效果很好:

public void PlotHeatMap (){

   OxyPlot.PlotModel model = new PlotModel { Title = "2-D data" };
   model.Axes.Add( new OxyPlot.Axes.LinearColorAxis { 
   Position = OxyPlot.Axes.AxisPosition.Right, 
   Palette = OxyPalettes.Jet( 500 ), 
   HighColor = OxyColors.Gray, 
   LowColor = OxyColors.Black } );

   OxyPlot.Series.HeatMapSeries heatmap = new OxyPlot.Series.HeatMapSeries {
     Data = ( Double[ , ] )data,
     X0 = x1min,
     X1 = x1max,
     Y0 = x2min,
     Y1 = x2max
    };

   model.Series.Add( heatmap );
}

HeatMapSeries的輸出

現在,當我嘗試使用ContourSeries時,我只是用ContourSeries替換了HeatMapSeries:

public void PlotContour (){

   OxyPlot.PlotModel model = new PlotModel { Title = "2-D data" };
   model.Axes.Add( new OxyPlot.Axes.LinearColorAxis { 
   Position = OxyPlot.Axes.AxisPosition.Right, 
   Palette = OxyPalettes.Jet( 500 ), 
   HighColor = OxyColors.Gray, 
   LowColor = OxyColors.Black } );

   OxyPlot.Series.ContourSeries contour = new OxyPlot.Series.ContourSeries {
      ColumnCoordinates = arrayFromMinToMax1,
      RowCoordinates = arrayFromMinToMax2,
      ContourLevels = arrayOfLevels,
      ContourColors = arrayOfColors, // Same # elements as the levels' array
      Data = ( Double[ , ] )data
    };

   model.Series.Add( contour );
}

這只是產生輸出:

ContourSeries嘗試的輸出

x軸和y軸在那里,並且與最小和最大坐標匹配,但是我看不到輪廓線。 我懷疑設置Axis會缺少一些東西(應該與HeatMapSeries一樣嗎?)。 我不知道如何進行等高線圖繪制。 除了GitHub上的ContourSeriesExamples之外,還有其他示例嗎?

謝謝你的幫助!

我終於找到了問題所在-這是我的錯誤! ColumnCoordinatesRowCoordinates數組必須匹配DoubleArray Data的大小! 而且我不確定他們是誰。 現在輪廓和熱圖對齊了! 感謝Anders的支持並將我推入自己的代碼!

具有輪廓的HeatMap

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM