public static PlotModel CreatePeaks(OxyPalette palette = null, bool includeContours = true, int n = 100) { double x0 = -3.1; double x1 = 3.1; double y0 = -3; double y1 = 3; 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); var xvalues = ArrayBuilder.CreateVector(x0, x1, n); var yvalues = ArrayBuilder.CreateVector(y0, y1, n); var peaksData = ArrayBuilder.Evaluate(peaks, xvalues, yvalues); var model = new PlotModel { Title = "Peaks" }; model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = palette ?? OxyPalettes.Jet(500), HighColor = OxyColors.Gray, LowColor = OxyColors.Black }); var hms = new HeatMapSeries { X0 = x0, X1 = x1, Y0 = y0, Y1 = y1, Data = peaksData }; model.Series.Add(hms); if (includeContours) { var cs = new ContourSeries { Color = OxyColors.Black, FontSize = 0, ContourLevelStep = 1, LabelBackground = OxyColors.Undefined, ColumnCoordinates = yvalues, RowCoordinates = xvalues, Data = peaksData }; model.Series.Add(cs); } return model; }
private static PlotModel CreateRandomScatterSeriesWithColorAxisPlotModel(int n, OxyPalette palette, MarkerType markerType, AxisPosition colorAxisPosition, OxyColor highColor, OxyColor lowColor) { var model = new PlotModel { Title = string.Format("ScatterSeries (n={0})", n), Background = OxyColors.LightGray }; var colorAxis = new LinearColorAxis { Position = colorAxisPosition, Palette = palette, Minimum = -1, Maximum = 1, HighColor = highColor, LowColor = lowColor }; model.Axes.Add(colorAxis); model.Series.Add(CreateRandomScatterSeries(n, markerType, false, true, colorAxis)); return model; }
public static PlotModel CreateRandomScatterSeriesWithColorAxisPlotModel(int n, OxyPalette palette, MarkerType markerType = MarkerType.Square, AxisPosition colorAxisPosition = AxisPosition.Right, OxyColor highColor = null, OxyColor lowColor = null) { var model = new PlotModel(string.Format("ScatterSeries (n={0})", n)) { Background = OxyColors.LightGray }; model.Axes.Add(new ColorAxis { Position = colorAxisPosition, Palette = palette, Minimum = -1, Maximum = 1, HighColor = highColor, LowColor = lowColor }); var s1 = new ScatterSeries { MarkerType = markerType, MarkerSize = 6, }; var random = new Random(); for (int i = 0; i < n; i++) { double x = random.NextDouble() * 2.2 - 1.1; s1.Points.Add(new ScatterPoint(x, random.NextDouble()) { Value = x }); } model.Series.Add(s1); return model; }
static public Mat GetPresetColorMat(string strPalette) { OxyPlot.OxyPalette palette = null; Mat colorMap = new Mat(maxLookUpTable, 1, Emgu.CV.CvEnum.DepthType.Cv8U, 3); Image <Bgr, byte> colorImage = new Image <Bgr, byte>(1, maxLookUpTable); switch (strPalette) { case "WhiteHot": palette = Palette.WhiteHot(maxLookUpTable); break; case "BlackHot": palette = Palette.BlackHot(maxLookUpTable); break; case "ColdHot": palette = Palette.ColdHot(maxLookUpTable); break; case "HotSpot": palette = Palette.HotSpot(maxLookUpTable); break; case "ColdSpot": palette = Palette.ColdSpot(maxLookUpTable); break; case "Rainbow": palette = Palette.Rainbow(maxLookUpTable); break; case "Ironbow": palette = Palette.Ironbow(maxLookUpTable); break; case "Cool": palette = OxyPlot.OxyPalettes.Cool(maxLookUpTable); break; case "Hot": palette = OxyPlot.OxyPalettes.Hot(maxLookUpTable); break; case "Gray": palette = OxyPlot.OxyPalettes.Gray(maxLookUpTable); break; case "Hue": palette = OxyPlot.OxyPalettes.Hue(maxLookUpTable); break; case "Jet": palette = OxyPlot.OxyPalettes.Jet(maxLookUpTable); break; case "Transparent": palette = OxyPalette.Interpolate(maxLookUpTable, OxyColors.Transparent); break; default: case "None": //palette = null; // palette = OxyPlot.OxyPalettes.Gray(maxLookUpTable); // Default "None" is gray break; } if (palette != null) { OxyColor[] colorTable = palette.Colors.ToArray(); IntPtr ptrData = colorMap.DataPointer; for (var index = 0; index < palette.Colors.Count; index++) { byte[] rgb = new byte[3] { colorTable[index].B, colorTable[index].G, colorTable[index].R }; Marshal.Copy(rgb, 0, ptrData + index * rgb.Length, rgb.Length); } } return(colorMap); }