Mat*_*son 8 c# wpf contour 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 );
}
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试使用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 );
}
Run Code Online (Sandbox Code Playgroud)
这只是产生输出:

x轴和y轴在那里,并匹配最小和最大坐标,但我看不到轮廓线.我怀疑设置轴时缺少一些东西(它应该与HeatMapSeries相同吗?).我不知道如何继续这个轮廓图.是否有其他例子,例如GitHub上的ContourSeriesExamples?
谢谢你的帮助!
我终于发现了问题所在——这是我的错误!和ColumnCoordinates数组RowCoordinates必须与 DoubleArray 的大小匹配 Data!我并不确定他们是。现在轮廓和热图对齐了!感谢 Anders 的支持并推动我编写自己的代码!

| 归档时间: |
|
| 查看次数: |
4020 次 |
| 最近记录: |