[英]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 );
}
现在,当我尝试使用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 );
}
这只是产生输出:
x轴和y轴在那里,并且与最小和最大坐标匹配,但是我看不到轮廓线。 我怀疑设置Axis会缺少一些东西(应该与HeatMapSeries一样吗?)。 我不知道如何进行等高线图绘制。 除了GitHub上的ContourSeriesExamples之外,还有其他示例吗?
谢谢你的帮助!
我终于找到了问题所在-这是我的错误! ColumnCoordinates
和RowCoordinates
数组必须匹配DoubleArray Data
的大小! 而且我不确定他们是谁。 现在轮廓和热图对齐了! 感谢Anders的支持并将我推入自己的代码!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.