I have a WPF application where I need to visualize y = y(x1, x2) where x1, x2 are linear coordinates. I can do this using the HeatMapSeries in Oxyplot, but when I want to plot two sets of data in the same window, heatmaps are not the proper tool. A couple of contour series would be better. Now, I have tried to achieve this in the same manner as with the HeatMapSeries, that worked pretty well:
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 );
}
Now, when I try to use the ContourSeries instead, I just replace the HeatMapSeries with a ContourSeries:
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 );
}
This just produce the output:
The x- and y-axes are there, and match the min and max coordinates, but I can see no contour lines. I suspect that there is something missing with setting up the Axis (should it be the same as for the HeatMapSeries??). I don't know how to proceed with this contour plot. Are there examples other than e.g. the ContourSeriesExamples at GitHub?
Thanks for any help!
ColumnCoordinates = arrayFromMinToMax2
andRowCoordinates = arrayFromMinToMax1
instead? – SchramContourSeries
decide the levels and colors itself, i.e. remove theContourLevels
andContourColors
properties from the initializer, and see if this gives any improved resut. – SchramContourSeries
work for that, then move on to your original dataset? By the way, why do you need to castdata
todouble[,]
? – SchramLinearColorAxis
to yourPlotModel
when you are plotting aContourSeries
. Also, could you publish thedata
array somewhere, e.g. as a Gist on Github or on ideone.com? Maybe the "flows" in the data compicates things for the contour generator? – Schram