void Seat_1_Update() //座墊-熱點計算更新 { this.Seat_1 = new PlotModel { Title = "" }; Seat_1.PlotAreaBorderColor = OxyColors.Transparent; Seat_1.Axes.Add(new OxyPlot.Axes.LinearColorAxis { Palette = OxyPalettes.Rainbow(500) }); Seat_1.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, IsAxisVisible = false }); Seat_1.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, IsAxisVisible = false }); #region 顏色距陣計算 // generate 1d normal distribution var singleDataSeat_1 = new double[100]; Random rndSeat_1 = new Random(); for (int x = 0; x < 100; ++x) { singleDataSeat_1[x] = Math.Exp((-1.0 / 2.0) * Math.Pow(((double)x - 50.0) / Convert.ToDouble(rndSeat_1.Next(900, 1200)), 2.0)); } // generate 2d normal distribution for (int x = 0; x < 100; ++x) { for (int y = 0; y < 100; ++y) { data_Seat_1[y, x] = singleDataSeat_1[x] * singleDataSeat_1[(y + 30) % 100] * 100; } } #endregion var heatMapSeat_1_Series = new HeatMapSeries { X0 = 0, X1 = 99, Y0 = 0, Y1 = 99, Interpolate = true, RenderMethod = HeatMapRenderMethod.Bitmap, Data = data_Seat_1 }; this.Seat_1.Series.Add(heatMapSeat_1_Series); }
public void PlotMirror(double w, double h) { var model = new PlotModel(); model.PlotType = PlotType.Cartesian; OxyPlot.Series.ScatterSeries sser = new OxyPlot.Series.ScatterSeries() { MarkerType = MarkerType.Square, BinSize = 2, MarkerSize = 0.75 }; sser.ItemsSource = m_Points; model.Series.Add(sser); model.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Bottom, Maximum = w / 2.0, Minimum = -w / 2.0, Title = "x, [mm]" }); model.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Left, Maximum = h / 2.0, Minimum = -h / 2.0, Title = "y, [mm]" }); model.Axes.Add(new OxyPlot.Axes.LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Rainbow(200), }); m_Canvas.Model = model; m_Canvas.InvalidatePlot(true); }
public static PlotModel PolarHeatMapRotatedCounterClockwisePi() { var model = new PlotModel { Title = "Polar heat map", PlotMargins = new OxyThickness(40, 80, 40, 40), PlotType = PlotType.Polar, PlotAreaBorderThickness = new OxyThickness(0) }; var matrix = new double[2, 2]; matrix[0, 0] = 0; matrix[0, 1] = 2; matrix[1, 0] = 1.5; matrix[1, 1] = 0.2; model.Axes.Add(new AngleAxis { StartAngle = Math.PI, EndAngle = Math.PI + 360, Minimum = 0, Maximum = 360, MajorStep = 30, MinorStep = 15 }); model.Axes.Add(new MagnitudeAxis { Minimum = 0, Maximum = 100, MajorStep = 25, MinorStep = 5 }); model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Rainbow(500), HighColor = OxyColors.Gray, LowColor = OxyColors.Black }); model.Series.Add(new PolarHeatMapSeries { Data = matrix, Angle0 = 30, Angle1 = 150, Magnitude0 = 0, Magnitude1 = 80, Interpolate = false }); return(model); }
public static PlotModel PolarHeatMapLinearAxes() { var model = new PlotModel { Title = "Polar heat map on linear axes" }; var matrix = new double[2, 2]; matrix[0, 0] = 0; matrix[0, 1] = 2; matrix[1, 0] = 1.5; matrix[1, 1] = 0.2; model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -100, Maximum = 100 }); model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0, Maximum = 100 }); model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Rainbow(500), HighColor = OxyColors.Gray, LowColor = OxyColors.Black }); model.Series.Add(new PolarHeatMapSeries { Data = matrix, Angle0 = 30, Angle1 = 150, Magnitude0 = 0, Magnitude1 = 80, Interpolate = true }); return(model); }
public PlotModel MagnifierColorImage(Image <Bgr, byte> colorImage) { CreateAxisForPlot(); plotImage.Axes.Add(new LinearColorAxis { Palette = OxyPalettes.Rainbow(255 * 255 * 255) }); var dataGreen = GenerateColorPixel(colorImage, 1); var dataRed = GenerateColorPixel(colorImage, 2); var dataBlue = GenerateColorPixel(colorImage, 0); var heatMapSeriesBlue = new HeatMapSeries { X0 = 0, X1 = 8, Y0 = 0, Y1 = 8, XAxisKey = "xAxis", YAxisKey = "yAxis", RenderMethod = HeatMapRenderMethod.Rectangles, LabelFontSize = 0.2, Interpolate = true, Data = dataBlue }; var heatMapSeriesGreen = new HeatMapSeries { X0 = 0, X1 = 8, Y0 = 0, Y1 = 8, XAxisKey = "xAxis", YAxisKey = "yAxis", RenderMethod = HeatMapRenderMethod.Rectangles, LabelFontSize = 0.2, Interpolate = true, Data = dataGreen }; var heatMapSeriesRed = new HeatMapSeries { X0 = 0, X1 = 8, Y0 = 0, Y1 = 8, XAxisKey = "xAxis", YAxisKey = "yAxis", RenderMethod = HeatMapRenderMethod.Rectangles, LabelFontSize = 0.2, Interpolate = true, Data = dataRed }; plotImage.Series.Add(heatMapSeriesBlue); plotImage.Series.Add(heatMapSeriesGreen); plotImage.Series.Add(heatMapSeriesRed); return(plotImage); }
public static void AssignDefaultColors( this PlotModel plotModel, bool isBaseDark, int nSeries ) { var palette = isBaseDark ? OxyPalettes.Cool(nSeries) : OxyPalettes.Rainbow(nSeries); plotModel.DefaultColors = palette.Colors; }
/// <summary> /// Create the palette list. /// </summary> private void CreatePaletteList() { PaletteList = new BindingList <OxyPalette>(); PaletteList.Add(OxyPalettes.BlackWhiteRed(64)); PaletteList.Add(OxyPalettes.BlueWhiteRed(64)); PaletteList.Add(OxyPalettes.BlueWhiteRed31); PaletteList.Add(OxyPalettes.Cool(64)); PaletteList.Add(OxyPalettes.Gray(64)); PaletteList.Add(OxyPalettes.Hot(64)); PaletteList.Add(OxyPalettes.Hue64); PaletteList.Add(OxyPalettes.HueDistinct(64)); PaletteList.Add(OxyPalettes.Jet(64)); PaletteList.Add(OxyPalettes.Rainbow(64)); }
public MainViewModel() { this.MyModel = new PlotModel { Title = "ContourSeries" }; this.MyModel.Axes.Add(new LinearColorAxis { Position = OxyPlot.Axes.AxisPosition.Right, //Palette = OxyPalettes.Jet(500) Palette = OxyPalettes.Rainbow(100) }); double x0 = -3.1; double x1 = 3.1; double y0 = -3; double y1 = 3; //generate values 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 xx = ArrayBuilder.CreateVector(x0, x1, 100); var yy = ArrayBuilder.CreateVector(y0, y1, 100); var peaksData = ArrayBuilder.Evaluate(peaks, xx, yy); var heatMapSeries = new HeatMapSeries { X0 = x0, X1 = x1, Y0 = y0, Y1 = y1, Interpolate = true, RenderMethod = HeatMapRenderMethod.Bitmap, Data = peaksData }; this.MyModel.Series.Add(heatMapSeries); var cs = new ContourSeries { Color = OxyColors.Black, LabelBackground = OxyColors.Transparent, ColumnCoordinates = yy, RowCoordinates = xx, Data = peaksData }; this.MyModel.Series.Add(cs); }
public override async Task OnInitializing() { var heatMapPlotModel = new Chart.PlotModel { Title = "HeatMapSeries" }; // Color axis (the X and Y axes are generated automatically) heatMapPlotModel.Axes.Add(new LinearColorAxis { Palette = OxyPalettes.Rainbow(100) }); // generate 1d normal distribution var singleData = new double[100]; for (int x = 0; x < 100; ++x) { singleData[x] = Math.Exp((-1.0 / 2.0) * Math.Pow(((double)x - 50.0) / 20.0, 2.0)); } // generate 2d normal distribution var data = new double[100, 100]; for (int x = 0; x < 100; ++x) { for (int y = 0; y < 100; ++y) { data[y, x] = singleData[x] * singleData[(y + 30) % 100] * 100; } } var heatMapSeries = new Chart.HeatMap { X0 = 0, X1 = 99, Y0 = 0, Y1 = 99, Interpolate = true, RenderMethod = HeatMapRenderMethod.Bitmap, Data = data }; heatMapPlotModel.Series.Add(heatMapSeries); await base.OnInitializing(); await heatMapPlotView.Add(heatMapPlotModel); }
private PlotModel InitialPolarScatterModel(string title = null) { var model = new PlotModel { Title = title, PlotType = PlotType.Polar, PlotAreaBorderThickness = new OxyThickness(0), PlotMargins = new OxyThickness(60, 20, 4, 40) }; model.Axes.Add( new AngleAxis { Title = "Angle", MajorStep = Math.PI / 4, MinorStep = Math.PI / 16, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, FormatAsFractions = true, FractionUnit = Math.PI, FractionUnitSymbol = "π", Minimum = 0, Maximum = 2 * Math.PI }); model.Axes.Add(new MagnitudeAxis { Title = "Magnitude", MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Solid, //Minimum = 0, //Maximum = 100, }); model.Axes.Add(new LinearColorAxis() // TODO Slot毎に上下限が変わるので色の変化も変えたほうが良いと思う { Position = AxisPosition.Left, Palette = OxyPalettes.Rainbow(16), //Minimum = 2000, //Maximum = 4000, HighColor = OxyColors.Magenta, LowColor = OxyColors.Green }); model.Series.Add(new ScatterSeries() // Order(ZIndex) が存在しない為、SeriesIndex順に描画される。その為、Zoneの前に実データを入れておく為、ここで暫定定義。後からSortで対応してもいいんだけどね { TrackerKey = Constants.TrackerKeyPlotData, }); AddZoneSeries(model); return(model); }
private void InitializeMainForm() { PlotModel plotModel = new PlotModel { Title = "EEG Data", DefaultColors = OxyPalettes.Rainbow(this.channelCount).Colors, LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.BottomLeft, LegendMaxWidth = 900.0, LegendMaxHeight = 100.0 }; plotModel.Axes.Add(new LinearAxis { Key = "X Axis", Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, Title = "Time", TextColor = OxyColors.Transparent, Minimum = 0.0, Maximum = (double)this.visData.GTEC_SAMPLE_BUFFER_SIZE, IsPanEnabled = false, IsZoomEnabled = false }); var tmp = new LinearAxis(); plotModel.Axes.Add(new LinearAxis { Key = "Y Axis", Position = AxisPosition.Left //AbsoluteMaximum = 1000, //AbsoluteMinimum = -1000 }); this.visData.visMainSeries = new LineSeries[this.channelCount]; for (int i = 0; i < this.channelCount; i++) { this.visData.visMainSeries[i] = new LineSeries { LineStyle = LineStyle.Solid, StrokeThickness = 1.0 }; plotModel.Series.Add(this.visData.visMainSeries[i]); } this.visMainPlot.Model = plotModel; }
public static PlotModel LinearHeatMap() { var model = new PlotModel { Title = "Heatmap" }; // Color axis (the X and Y axes are generated automatically) model.Axes.Add(new LinearColorAxis { Palette = OxyPalettes.Rainbow(100) }); // generate 1d normal distribution var singleData = new double[100]; for (int x = 0; x < 100; ++x) { singleData[x] = Math.Exp((-1.0 / 2.0) * Math.Pow(((double)x - 50.0) / 20.0, 2.0)); } // generate 2d normal distribution var data = new double[100, 100]; for (int x = 0; x < 100; ++x) { for (int y = 0; y < 100; ++y) { data[y, x] = singleData[x] * singleData[(y + 30) % 100] * 100; } } var heatMapSeries = new HeatMapSeries { X0 = 0, X1 = 99, Y0 = 0, Y1 = 99, Interpolate = true, RenderMethod = HeatMapRenderMethod.Bitmap, Data = data }; model.Series.Add(heatMapSeries); return(model); }
public static Points2DCollectionsViewer BuildViewer(IEnumerable <Point2D> PointsWithTag, string Title, int min, int max) { Points2DCollectionsViewer viewer = new Points2DCollectionsViewer(); viewer.Text = Title; var model = new PlotModel { Title = viewer.Text }; var scatterSeries = new ScatterSeries { MarkerType = MarkerType.Circle }; foreach (var point in PointsWithTag) { scatterSeries.Points.Add(new ScatterPoint(point.x, point.y, 2, TagToValue(point.Tag))); } model.Series.Add(scatterSeries); model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Rainbow(TagToValueDict.Count() + 1) }); model.Axes.Add(new LinearAxis() { Minimum = min, Maximum = max, Position = AxisPosition.Bottom }); model.Axes.Add(new LinearAxis() { Minimum = min, Maximum = max, Position = AxisPosition.Left }); viewer.plotView.Model = model; return(viewer); }
private OxyPalette GetPalette(int numberOfColors) => _appSettings.IsBaseDark ? OxyPalettes.Cool(numberOfColors) : OxyPalettes.Rainbow(numberOfColors);
/// <summary> /// Generates an OxyPlot plot model. /// </summary> /// <param name="yMin">Minimum value for the vertical axis. If NaN will find the lowest value.</param> /// <param name="yMax">Maximum value for the vertical axis. If NaN will find the highest value.</param> /// <returns></returns> public PlotModel Plot(double yMin, double yMax) { // Check if experiment has run yet if (results == null) { throw new InvalidOperationException("Experiment has not been run yet."); } // Check if yMin is valid if (double.IsNaN(yMin)) { yMin = double.PositiveInfinity; } // Check if yMax is valid if (double.IsNaN(yMax)) { yMax = double.NegativeInfinity; } // Expand yMin and yMax so all values fit for (int i = 0; i < N; i++) { if (i != HorizontalAxis) { double min = GetStatistics(i).Select(statistic => statistic.Min).Min(); if (yMin > min) { yMin = min; } double max = GetStatistics(i).Select(statistic => statistic.Max).Max(); if (yMax < max) { yMax = max; } } } // Arbitrary small value to prevent clipping yMin -= 0.001; yMax += 0.001; // Create OxyPlot series List <Series> series = new List <Series>(); for (int i = 0; i < N; i++) { if (i != HorizontalAxis) { var color = OxyPalettes.Rainbow(N).Colors[i]; var mySeries = new ErrorLineSeries() { Color = color, MarkerFill = color, MarkerSize = 5, MarkerStroke = OxyColors.White, MarkerType = MarkerType.Diamond, Title = Labels[i], ErrorValues = GetStatistics(i).Select(statistic => statistic.StdDev).ToList(), ErrorWidth = 0.1, }; mySeries.Points.AddRange(GetStatistics(i).Select((statistic, j) => new DataPoint(GetStatistics(HorizontalAxis)[j].Mean, statistic.Mean)).ToList()); series.Add(mySeries); } } // Create OxyPlot model var plotModel = new PlotModel() { Title = string.Join(", ", Meta), LegendSymbolLength = 16, LegendPlacement = OxyPlot.LegendPlacement.Outside }; plotModel.Axes.Add(new LinearAxis() { Minimum = yMin, Maximum = yMax, Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, }); plotModel.Axes.Add(new LinearAxis() { Minimum = GetStatistics(HorizontalAxis).Select(statistic => statistic.Min).Min(), Maximum = GetStatistics(HorizontalAxis).Select(statistic => statistic.Max).Max(), Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, Title = Labels[HorizontalAxis], }); foreach (var sery in series) { plotModel.Series.Add(sery); } return(plotModel); }
private void Plot_btn_Click(object sender, RoutedEventArgs e) { try { var tmp = new PlotModel { Title = "Contour Plot", Subtitle = "f(x1,x2)" }; tmp.Axes.Add(new LinearColorAxis { Position = OxyPlot.Axes.AxisPosition.Right, //Palette = OxyPalettes.Jet(500) Palette = OxyPalettes.Rainbow(100) }); double[] PVBmax = ParsePVB(PVBmax_TextBox.Text, ';'); double[] PVBmin = ParsePVB(PVBmin_TextBox.Text, ';'); bool errFlag = false; for (int i = 0; i < PVBmax.Length; i++) { if (PVBmax[i] <= PVBmin[i]) { errFlag = true; } } String fun_str = ObjFun_ComboBox.Text.ToString(); Function fn = new Function(fun_str); double x1_min; double x1_max; double x2_min; double x2_max; double tmpMaxValue = Double.MinValue; if (PVBmin.GetLength(0) == 2 && !errFlag) { x1_min = PVBmin[0]; x1_max = PVBmax[0]; x2_min = PVBmin[1]; x2_max = PVBmax[1]; var x1x1 = ArrayBuilder.CreateVector(x1_min, x1_max, 100); var x2x2 = ArrayBuilder.CreateVector(x2_min, x2_max, 100); double[,] peaksData = new double[x1x1.GetLength(0), x2x2.GetLength(0)]; double[] xy_tab = new double[2]; for (int i = 0; i < x1x1.GetLength(0); i++) { for (int j = 0; j < x2x2.GetLength(0); j++) { xy_tab[0] = x1x1[i]; xy_tab[1] = x2x2[j]; peaksData[i, j] = HarmonyTool.EvaluateFun(fn, xy_tab); if (peaksData[i, j] > tmpMaxValue) { tmpMaxValue = peaksData[i, j]; } } } var heatMapSeries = new HeatMapSeries { X0 = x1_min, X1 = x1_max, Y0 = x2_min, Y1 = x2_max, Interpolate = true, RenderMethod = HeatMapRenderMethod.Bitmap, Data = peaksData }; tmp.Series.Add(heatMapSeries); var cs = new ContourSeries { Color = OxyColors.Black, LabelBackground = OxyColors.Transparent, ColumnCoordinates = x1x1, RowCoordinates = x2x2, Data = peaksData }; tmp.Series.Add(cs); if (solutionCheckBox.IsChecked == true) { var sc = new ScatterSeries { MarkerType = MarkerType.Circle }; sc.BinSize = 10; sc.MarkerType = MarkerType.Cross; sc.MarkerStrokeThickness = 3; sc.MarkerStroke = OxyColors.Black; double x1 = bestSolution[0]; double x2 = bestSolution[1]; sc.Points.Add(new OxyPlot.Series.ScatterPoint(x1, x2, 5, tmpMaxValue)); tmp.Series.Add(sc); } GetMainViewModel().MyModel = tmp; } else { MessageBox.Show("Number of variables does not equal n = 2 or PVB not given correctly! Check forms", "Exception", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { MessageBox.Show("A handled exception just occurred: " + ex.Message + "\n Check if forms are filled properly! Domain of function has to be set in PVB forms", "Exception", MessageBoxButton.OK, MessageBoxImage.Information); } }
public static OxyPaletteMap CreateFromName(string name) { OxyPalette palette = null; var numPoints = 2; switch (name) { case "BlackWhiteRed": { numPoints = 3; palette = OxyPalettes.BlackWhiteRed(NUM_COLORS); break; } case "BlueWhiteRed": { numPoints = 3; palette = OxyPalettes.BlueWhiteRed(NUM_COLORS); break; } case "Cool": { numPoints = 3; palette = OxyPalettes.Cool(NUM_COLORS); break; } case "Gray": { numPoints = 2; palette = OxyPalettes.Gray(NUM_COLORS); break; } case "Hot": { numPoints = 5; palette = OxyPalettes.Hot(NUM_COLORS); break; } case "Hue": { numPoints = 7; palette = OxyPalettes.Hue(NUM_COLORS); break; } case "Jet": { numPoints = 5; palette = OxyPalettes.Jet(NUM_COLORS); break; } case "Rainbow": { numPoints = 7; palette = OxyPalettes.Rainbow(NUM_COLORS); break; } default: { return(null); break; } } var colorPoints = new Color[7]; var brush = new LinearGradientBrush(); brush.StartPoint = new Point(0, 0.5); brush.EndPoint = new Point(1, 0.5); var division = (NUM_COLORS / (numPoints - 1)) - 1; for (int i = 0; i < numPoints; i++) { var oxyColor = palette.Colors[(division * i)]; colorPoints[i] = Color.FromArgb(oxyColor.A, oxyColor.R, oxyColor.G, oxyColor.B); brush.GradientStops.Add(new GradientStop(colorPoints[i], ((double)i / (numPoints - 1)))); } return(new OxyPaletteMap(name, brush, palette)); }
private static PlotModel GetPlot(string name) { // RESOLUTION AND TICK SIZE int dpi = (int)(dpi_min + _random.NextDouble() * (dpi_max - dpi_min)); int[] figsize = new[] { (int)(figsize_min + _random.NextDouble() * (figsize_max - figsize_min)), (int)(figsize_min + _random.NextDouble() * (figsize_max - figsize_min)) }; List <double> tick_size = new List <double> { (tick_size_width_min + _random.NextDouble() * (tick_size_width_max - tick_size_width_min)), (tick_size_length_min + _random.NextDouble() * (tick_size_length_max - tick_size_length_min)) }; tick_size.Sort(); // ACTUAL POINTS var points_nb = (int)(points_nb_min + (Math.Pow(_random.NextDouble(), 1.5)) * (points_nb_max - points_nb_min)); var x_scale = (int)(x_min_top + _random.NextDouble() * (x_max_top - x_min_top)); var y_scale = (int)(y_min_top + _random.NextDouble() * (y_max_top - y_min_top)); var x_scale_range = x_scale + (int)(_random.NextDouble() * x_scale_range_max); var y_scale_range = y_scale + (int)(_random.NextDouble() * y_scale_range_max); var x_min_temp = (-_random.NextDouble() + _random.NextDouble()) * Math.Pow(10, x_scale); var x_max_temp = (-_random.NextDouble() + _random.NextDouble()) * Math.Pow(10, x_scale_range); var x_min = Math.Min(x_min_temp, x_max_temp); var x_max = Math.Max(x_min_temp, x_max_temp); var y_min_temp = (-_random.NextDouble() + _random.NextDouble()) * Math.Pow(10, y_scale); var y_max_temp = (-_random.NextDouble() + _random.NextDouble()) * Math.Pow(10, y_scale_range); var y_min = Math.Min(y_min_temp, y_max_temp); var y_max = Math.Max(y_min_temp, y_max_temp); var xs = UniformContinuousDistribution.Random(x_min, x_max, points_nb, _random); double[] ys = new double[0]; var distribution = Resources.point_dist[_random.Next(4)]; if (distribution == "uniform") { ys = UniformContinuousDistribution.Random(y_min, y_max, points_nb, _random); } else if (distribution == "linear") { ys = xs.Multiply((Math.Max(y_max, -y_min) / (Math.Max(x_max, -x_min)))).Multiply((double)Resources.updown[_random.Next(2)]) .Add(UniformContinuousDistribution.Random(0, 1, points_nb, _random).Add(y_min).Multiply((y_max - y_min)).Multiply(_random.NextDouble() / 2.0)); } else if (distribution == "quadratic") { ys = xs.Pow(2).Multiply(1.0 / (Math.Max(x_max, -x_min))).Pow(2).Multiply(Math.Max(y_max, -y_min)).Multiply((double)Resources.updown[_random.Next(2)]) .Add(UniformContinuousDistribution.Random(0, 1, points_nb, _random).Add(y_min).Multiply((y_max - y_min)).Multiply(_random.NextDouble() / 2.0)); } else if (distribution == "binormal") { double stdDev = Math.Max(y_max, -y_min) / Math.Max(x_max, -x_min); double correl = (double)Resources.updown[_random.Next(2)] * _random.NextDouble(); xs = NormalDistribution.Random(x_max - x_min, stdDev, points_nb, _random); ys = correl.Multiply(xs).Add(NormalDistribution.Random(y_max - y_min, stdDev, points_nb, _random).Multiply(Math.Sqrt(1 - correl * correl))); } // POINTS VARIATION var nb_points_var = 1 + (int)(_random.NextDouble() * max_points_variations); var nb_points_var_colors = 1 + (int)(_random.NextDouble() * nb_points_var); var nb_points_var_markers = 1 + (int)(_random.NextDouble() * (nb_points_var - nb_points_var_colors)); var nb_points_var_size = Math.Max(1, 1 + nb_points_var - nb_points_var_colors - nb_points_var_markers); var rand_color_number = _random.NextDouble(); OxyColor[] colors = new OxyColor[nb_points_var_colors]; OxyColor[] tempPalette; if (rand_color_number <= 0.5) { tempPalette = OxyPalettes.Rainbow(nb_points_var_colors * 20).Colors.ToArray(); } else if (rand_color_number > 0.5 && rand_color_number <= 0.7) { tempPalette = OxyPalettes.Hue(nb_points_var_colors * 20).Colors.ToArray(); // gnuplot } else if (rand_color_number > 0.7 && rand_color_number <= 0.8) { tempPalette = OxyPalettes.Hot(nb_points_var_colors * 20).Colors.ToArray(); // copper } else { tempPalette = OxyPalettes.Jet(nb_points_var_colors * 20).Colors.ToArray(); // gray } for (int i = 0; i < nb_points_var_colors; i++) { colors[i] = tempPalette[_random.Next(nb_points_var_colors * 20)]; } var s_set = (size_points_min.Add(UniformContinuousDistribution.Random(0, 1, nb_points_var_size, _random).Multiply(size_points_max - size_points_min))); var markers_subset = new List <MarkerType>(); for (int i = 0; i < nb_points_var_markers; i++) { markers_subset.Add(Resources.Markers[_random.Next(Resources._markersCount)]); } var markers_empty = _random.NextDouble() > 0.75; var markers_empty_ratio = new[] { 0.0, 0.5, 0.7 }[_random.Next(3)]; // PAD BETWEEN TICKS AND LABELS double pad_x = Math.Max(tick_size[1] + 0.5, (int)(pad_min + _random.NextDouble() * (pad_max - pad_min))); double pad_y = Math.Max(tick_size[1] + 0.5, (int)(pad_min + _random.NextDouble() * (pad_max - pad_min))); TickStyle direction_ticks_x = Resources.DirectionTicks[_random.Next(Resources._directionTicksCount)]; TickStyle direction_ticks_y = Resources.DirectionTicks[_random.Next(Resources._directionTicksCount)]; // FONT AND SIZE FOR LABELS (tick labels, axes labels and title) string font = Resources.FontList[_random.Next(Resources._fontListCount)]; int size_ticks = (int)(tick_label_size_min + _random.NextDouble() * (tick_label_size_max - tick_label_size_min)); int size_axes = (int)(axes_label_size_min + _random.NextDouble() * (axes_label_size_max - axes_label_size_min)); int size_title = (int)(title_size_min + _random.NextDouble() * (title_size_max - title_size_min)); //var ticks_font = font_manager.FontProperties(fname = font, style = 'normal', size = size_ticks, weight = 'normal', stretch = 'normal'); //var axes_font = font_manager.FontProperties(fname = font, style = 'normal', size = size_axes, weight = 'normal', stretch = 'normal'); //var title_font = font_manager.FontProperties(fname = font, style = 'normal', size = size_title, weight = 'normal', stretch = 'normal'); // TEXTS FOR AXIS LABELS AND TITLE int label_x_length = (int)(axes_label_length_min + _random.NextDouble() * (axes_label_length_max - axes_label_length_min)); int label_y_length = (int)(axes_label_length_min + _random.NextDouble() * (axes_label_length_max - axes_label_length_min)); int title_length = (int)(title_length_min + _random.NextDouble() * (title_length_max - title_length_min)); string x_label = RandomString(label_x_length); string y_label = RandomString(label_y_length); string title = RandomString(title_length); // BUILDING THE PLOT PlotModel model = new PlotModel { Title = title, TitleFont = font, TitleFontSize = size_title, DefaultColors = colors, PlotAreaBorderThickness = new OxyThickness(0) }; model.Axes.Add(new LinearColorAxis { Position = AxisPosition.None, Palette = new OxyPalette(colors), Minimum = 0, Maximum = colors.Length - 1 }); // TICKS STYLE AND LOCATION (X AXIS) LineStyle lineStyle = Resources.LineStyles[_random.Next(Resources._lineStylesCount)]; var xAxis = new LinearAxis { Position = _random.NextDouble() > 0.5 ? AxisPosition.Top : AxisPosition.Bottom, TickStyle = direction_ticks_x, MajorGridlineStyle = lineStyle, MajorTickSize = tick_size[1], MinorTickSize = (_random.NextDouble() > 77) ? 0.75 * _random.NextDouble() * tick_size[1] : 0, Angle = _random.NextDouble() > 0.77 ? _random.NextDouble() * (double)Resources.updown[_random.Next(2)] * 90 : 0, Font = font, FontSize = size_ticks, TitleFont = font, TitleFontSize = size_axes, Title = _random.NextDouble() > 0.80 ? "" : x_label, PositionAtZeroCrossing = (_random.NextDouble() > 0.77), IsAxisVisible = true, AxislineColor = OxyColors.Black, AxislineStyle = LineStyle.Solid }; model.Axes.Add(xAxis); // TICKS STYLE AND LOCATION (Y AXIS) var yAxis = new LinearAxis { Position = _random.NextDouble() > 0.5 ? AxisPosition.Right : AxisPosition.Left, TickStyle = direction_ticks_y, MajorGridlineStyle = lineStyle, MajorTickSize = tick_size[1], MinorTickSize = (_random.NextDouble() > 77) ? 0.75 * _random.NextDouble() * tick_size[1] : 0, Angle = _random.NextDouble() > 0.77 ? _random.NextDouble() * 90 : 0, Font = font, FontSize = size_ticks, TitleFont = font, TitleFontSize = size_axes, Title = _random.NextDouble() > 0.80 ? "" : y_label, PositionAtZeroCrossing = (_random.NextDouble() > 0.77), IsAxisVisible = true, AxislineColor = OxyColors.Black, AxislineStyle = LineStyle.Solid }; model.Axes.Add(yAxis); MarkerType markerType = Resources.Markers[_random.Next(Resources._markersCount)]; var scatterSerie = new ScatterSeries() { MarkerType = markerType, MarkerStrokeThickness = _random.Next(10, 31) / 10, }; if (markerType != MarkerType.Cross && markerType != MarkerType.Plus && markerType != MarkerType.Star) { if (_random.NextDouble() > 0.5) { scatterSerie.MarkerStroke = OxyColors.Black; } } List <double> s = new List <double>(); for (int i = 0; i < points_nb; i++) { var s_ = s_set[_random.Next(s_set.Length)]; var c_ = colors[_random.Next(colors.Length)]; var m_ = Resources.Markers[_random.Next(Resources._markersCount)]; bool e_ = false; if (markers_empty) { e_ = _random.NextDouble() > markers_empty_ratio; } scatterSerie.Points.Add(new ScatterPoint(xs[i], ys[i], s_, _random.Next(colors.Length))); } model.Series.Add(scatterSerie); return(model); }
public static PlotModel ColorMapRainbow16() { return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Rainbow(16), MarkerType.Square, AxisPosition.Right, OxyColors.Undefined, OxyColors.Undefined)); }
public PlotView getScatteredPlot(string[,] dataArray, string title, int xColumn, int yColumn, int colorColumn, int regressionIndex, bool logX, bool logY) { string xTitle = ucLoadFile.Instance.getCurrentColumnNames()[xColumn]; string yTitle = ucLoadFile.Instance.getCurrentColumnNames()[yColumn]; string colorTitle = "No grouping selected"; if (colorColumn != -1) { colorTitle = ucLoadFile.Instance.getCurrentColumnNames()[colorColumn]; } // Getting unique group names when color grouping required and groups are strings ArrayList groupNames = getGroupNames(dataArray, colorColumn); //Populating scatter plot with data from selected columns var model = new PlotModel { Title = title }; var scatterSeries = new ScatterSeries { MarkerType = MarkerType.Circle }; for (int r = 0; r < dataArray.GetLength(0); r++) { // x axis double xDouble = 0; bool isNumberX = double.TryParse(dataArray[r, xColumn], out xDouble); var x = xDouble; // y axis double yDouble = 0; bool isNumberY = double.TryParse(dataArray[r, yColumn], out yDouble); var y = yDouble; // color grouping double colorValue = 0; bool isNumberColor = true; if (colorColumn != -1) { double colorDouble = 0; isNumberColor = double.TryParse(dataArray[r, colorColumn], out colorDouble); colorValue = colorDouble; } var size = 3; if (!isNumberColor && !String.IsNullOrEmpty(dataArray[r, colorColumn])) { scatterSeries.Points.Add(new ScatterPoint(x, y, size, groupNames.IndexOf(dataArray[r, colorColumn]))); } else { scatterSeries.Points.Add(new ScatterPoint(x, y, size, colorValue)); } } // Handling of selection of axis scaling if (logX && !logY) { var logAxisX = new LogarithmicAxis() { Position = AxisPosition.Bottom, Title = xTitle + ", Log(x)", UseSuperExponentialFormat = false, Base = 10, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray }; var linearAxisY = new LinearAxis() { Position = AxisPosition.Left, Title = yTitle, UseSuperExponentialFormat = false, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray }; model.Axes.Add(logAxisX); model.Axes.Add(linearAxisY); } else if (!logX && logY) { var linearAxisX = new LinearAxis() { Position = AxisPosition.Bottom, Title = xTitle, UseSuperExponentialFormat = false, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray }; var logAxisY = new LogarithmicAxis() { Position = AxisPosition.Left, Title = yTitle + ", Log(y)", UseSuperExponentialFormat = false, Base = 10, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray }; model.Axes.Add(linearAxisX); model.Axes.Add(logAxisY); } else if (logX && logY) { var logAxisX = new LogarithmicAxis() { Position = AxisPosition.Bottom, Title = xTitle + ", Log(x)", UseSuperExponentialFormat = false, Base = 10, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray }; var logAxisY = new LogarithmicAxis() { Position = AxisPosition.Left, Title = yTitle + ", Log(y)", UseSuperExponentialFormat = false, Base = 10, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray }; model.Axes.Add(logAxisY); model.Axes.Add(logAxisX); } else { var linearAxisX = new LinearAxis() { Position = AxisPosition.Bottom, Title = xTitle, UseSuperExponentialFormat = false, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray }; var linearAxisY = new LinearAxis() { Position = AxisPosition.Left, Title = yTitle, UseSuperExponentialFormat = false, MajorGridlineStyle = LineStyle.Dot, MajorGridlineColor = OxyColors.Gray }; model.Axes.Add(linearAxisX); model.Axes.Add(linearAxisY); } model.Series.Clear(); model.Annotations.Clear(); model.Series.Add(scatterSeries); // Adding regression graph when selected if (regressionIndex == 1) { double[] xClmn = parseDataArrayToDouble(ucLoadFile.Instance.getDataColumn(xColumn, dataArray)); Func <double, double> pwr = getPowerRegression(dataArray, xColumn, yColumn); string label = "pwr rgssn y=" + Math.Round(a, 3).ToString() + "*" + "x pwr" + Math.Round(b, 3).ToString() + ", r=" + Math.Round(r, 2).ToString(); FunctionSeries fsPwrRegression = new FunctionSeries(pwr, xClmn.Min() - 0.1, xClmn.Max(), 0.01, label); fsPwrRegression.Color = OxyColors.DeepSkyBlue; model.Series.Add(fsPwrRegression); } if (regressionIndex == 2) { double[] xClmn = parseDataArrayToDouble(ucLoadFile.Instance.getDataColumn(xColumn, dataArray)); Func <double, double> lnr = getLinearRegression(dataArray, xColumn, yColumn); string bstring = Math.Round(b, 3).ToString(); if (b <= 0.0009) { bstring = Math.Round(b * 1000000, 3).ToString() + "m"; } string label = "lnr rgssn y=" + Math.Round(a, 3).ToString() + "+" + bstring + "*x, r=" + Math.Round(r, 2).ToString(); FunctionSeries fsLinearRegression = new FunctionSeries(lnr, xClmn.Min() - 0.1, xClmn.Max(), 0.01, label); fsLinearRegression.Color = OxyColors.DeepSkyBlue; model.Series.Add(fsLinearRegression); } // Adding special axis for color coding model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Top, Palette = OxyPalettes.Rainbow(200), Title = colorTitle, TitlePosition = 0.2, }); PlotView plotView = new PlotView(); // Adding assembled model into plot view plotView.Model = model; return(plotView); }
public static PlotModel Rainbow7() { return(HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Rainbow(7), false)); }
public static PlotModel ColorMapRainbow16() { return(CreateRandomScatterSeriesWithColorAxisPlotModel(2500, OxyPalettes.Rainbow(16))); }
private PlotModel InitialScatterModel(string title = null) { var model = new PlotModel() { Title = title, LegendPlacement = LegendPlacement.Outside, }; var xAxis = new LinearAxis() { Minimum = -1, Maximum = 1, Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Automatic, Title = "x" }; model.Axes.Add(xAxis); var yAxis = new LinearAxis() { Minimum = -1, Maximum = 1, Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Automatic, Title = "y" }; model.Axes.Add(yAxis); var s1 = new ScatterSeries() { Title = "Diamond", MarkerType = MarkerType.Diamond, MarkerStrokeThickness = 0, BinSize = 1, }; var random = new Random(Environment.TickCount); for (int i = 0; i < 50; i++) { var x = random.NextDouble(); var y = random.NextDouble(); var z = random.NextDouble(); s1.Points.Add(new ScatterPoint(x, y) { Value = z }); } model.Series.Add(s1); model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Rainbow(16), Minimum = -1, Maximum = 1, HighColor = OxyColors.Magenta, LowColor = OxyColors.Green }); var s2 = new ScatterSeries { Title = "star", MarkerType = MarkerType.Star, MarkerSize = 6, }; for (int i = 0; i < 50; i++) { var x = random.NextDouble(); int odd = (int)(x * 100) % 2; x = x * ((odd == 0) ? 1: -1); var y = random.NextDouble(); odd = (int)(y * 100) % 2; y = y * ((odd == 0) ? 1 : -1); var z = random.NextDouble(); odd = (int)(z * 100) % 2; z = z * ((odd == 0) ? 1 : -1); s2.Points.Add(new ScatterPoint(x, y) { Value = z }); } model.Series.Add(s2); return(model); }