public static PlotModel ColorCodingOnScatterPlots() { var model = new PlotModel { Title = "Colour coding on scatter plots" }; var colorAxis = new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Jet(500), Minimum = 0, Maximum = 5, HighColor = OxyColors.Gray, LowColor = OxyColors.Black }; model.Axes.Add(colorAxis); var s4 = new ScatterSeries { MarkerType = MarkerType.Circle }; s4.Points.Add(new ScatterPoint(3, 5, 5, 0)); s4.Points.Add(new ScatterPoint(5, 5, 7, 0)); s4.Points.Add(new ScatterPoint(2, 4, 5, 0.3)); s4.Points.Add(new ScatterPoint(3, 3, 8, 0)); s4.Points.Add(new ScatterPoint(3, 2, 5, 0)); s4.Points.Add(new ScatterPoint(3, 5, 8, 1)); s4.Points.Add(new ScatterPoint(2, 2, 3, 5)); s4.Points.Add(new ScatterPoint(1, 4, 4, 1)); s4.Points.Add(new ScatterPoint(4, 3, 5, 3)); s4.Points.Add(new ScatterPoint(0, 0, 1, 1)); s4.Points.Add(new ScatterPoint(8, 8, 1, 1)); model.Series.Add(s4); return(model); }
public void UpdateMap(string field, double[,] values, double x0, double x1, double y0, double y1) { PlotModelPP.Title = field; heatMapSeries = new HeatMapSeries(); heatMapSeries.Interpolate = true; heatMapSeries.Data = values; heatMapSeries.X0 = x0; heatMapSeries.X1 = x1; heatMapSeries.Y0 = y0; heatMapSeries.Y1 = y1; PlotModelPP.Series.Clear(); PlotModelPP.Series.Add(heatMapSeries); PlotModelPP.Axes.Clear(); var linearColorAxis = new LinearColorAxis(); linearColorAxis.HighColor = OxyColors.Gray; linearColorAxis.LowColor = OxyColors.Black; linearColorAxis.Position = AxisPosition.Right; PlotModelPP.Axes.Add(linearColorAxis); linearAxisX = new LinearAxis(); linearAxisX.Position = AxisPosition.Bottom; linearAxisX.Minimum = x0; linearAxisX.Maximum = x1; PlotModelPP.Axes.Add(linearAxisX); linearAxisY = new LinearAxis(); linearAxisY.Position = AxisPosition.Left; linearAxisY.Minimum = y0; linearAxisY.Maximum = y1; PlotModelPP.Axes.Add(linearAxisY); }
public void InitializeSscan() { InitSscanModel(); plotSscanModel = new PlotModel { Title = "Sscan plotting", }; var axis = new LinearColorAxis { Position = AxisPosition.Right, StartPosition = 0, EndPosition = 1, }; plotSscanModel.Axes.Add(axis); heatmapSeries = new HeatMapSeries { X0 = sscanModel.XAxis.Min, X1 = sscanModel.XAxis.Max, Y1 = sscanModel.YAxis.Min, Y0 = sscanModel.YAxis.Max, Interpolate = true, RenderMethod = HeatMapRenderMethod.Bitmap, Data = plottingData, }; plotSscanModel.Series.Add(heatmapSeries); }
public MainWindow() { InitializeComponent(); Model = new PlotModel(); var axis1 = new LinearColorAxis(); axis1.Key = "ColorAxis"; axis1.Maximum = 2 * Math.PI; axis1.Minimum = 0; axis1.Position = AxisPosition.Top; Model.Axes.Add(axis1); var s1 = new ScatterSeries(); s1.ColorAxisKey = "ColorAxis"; s1.MarkerSize = 8; s1.MarkerType = MarkerType.Circle; for (double x = 0; x <= 2 * Math.PI; x += 0.1) { s1.Points.Add(new ScatterPoint(x, Math.Sin(x), double.NaN, x)); } Model.Series.Add(s1); DataContext = this; }
public PlotModel GetNewModel(string title = "", string xname = "", string yname = "") { var m = new PlotModel { Title = title }; var linearAxis1 = new LinearAxis(); linearAxis1.MajorGridlineStyle = LineStyle.Solid; linearAxis1.MaximumPadding = 0; linearAxis1.MinimumPadding = 0; linearAxis1.MinorGridlineStyle = LineStyle.Dot; linearAxis1.Position = AxisPosition.Bottom; linearAxis1.Title = xname; m.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis(); linearAxis2.MajorGridlineStyle = LineStyle.Solid; linearAxis2.MaximumPadding = 0; linearAxis2.MinimumPadding = 0; linearAxis2.MinorGridlineStyle = LineStyle.Dot; linearAxis2.Title = yname; m.Axes.Add(linearAxis2); colorAxis = new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Jet(200), Minimum = 0, Maximum = 1 }; m.Axes.Add(colorAxis); return(m); }
public void PlotData(List <HDUBinaryTable> tables, Query query) { ResetDataAndColourBar(); ScatterSeries scatterSeries; foreach (HDUBinaryTable table in tables) { scatterSeries = new ScatterSeries { MarkerType = MarkerType.Square }; foreach (Pixel pixel in table.Pixels) { if (EvaluateQueries(pixel.Weight, query)) { scatterSeries.Points.Add(new ScatterPoint(pixel.X, pixel.Y, 3, pixel.Weight)); } } PlotModel.Series.Add(scatterSeries); } LinearColorAxis heatAxis = new LinearColorAxis { Position = AxisPosition.Right, HighColor = OxyColors.OrangeRed, LowColor = OxyColors.BlueViolet }; PlotModel.Axes.Add(heatAxis); PlotModel.InvalidatePlot(true); }
//public PlotModel display_heatMap() //{ // var model = new PlotModel(); // model.Title = "Cos Similarity"; // var linearAxis1 = new LinearAxis(); // linearAxis1.Position = AxisPosition.Bottom; // model.Axes.Add(linearAxis1); // var linearAxis2 = new LinearAxis(); // model.Axes.Add(linearAxis2); // return model; //} public PlotModel display_heatMap() { var model = new PlotModel(); model.Title = "Cos Similarity"; var linearColorAxis1 = new LinearColorAxis(); linearColorAxis1.HighColor = OxyColors.Gray; linearColorAxis1.LowColor = OxyColors.Black; linearColorAxis1.Position = AxisPosition.Right; model.Axes.Add(linearColorAxis1); var linearAxis1 = new LinearAxis(); linearAxis1.Position = AxisPosition.Bottom; linearAxis1.Minimum = Min; linearAxis1.Maximum = Max; model.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis(); linearAxis2.Minimum = Min; linearAxis2.Maximum = Max; model.Axes.Add(linearAxis2); var heatMapSeries1 = new HeatMapSeries(); heatMapSeries1.X0 = 0; heatMapSeries1.X1 = 1.0; heatMapSeries1.Y0 = 0; heatMapSeries1.Y1 = 1.0; heatMapSeries1.Interpolate = false; heatMapSeries1.Data = new Double[Scores.Count, Scores.Count]; for (int i = 0; i < Scores.Count; ++i) { for (int j = 0; j < Scores.Count; ++j) { heatMapSeries1.Data[i, j] = Scores[i][j]; } } model.Series.Add(heatMapSeries1); heatMapSeries1.MouseDown += (s, e) => { DataPoint point = model.Axes[1].InverseTransform(e.Position.X, e.Position.Y, model.Axes[2]); int x_index = (int)((point.X - this.Min) / this.Width); int y_index = (int)((point.Y - this.Min) / this.Width); if (x_index < 0 || x_index >= Ncs.Count || y_index < 0 || y_index >= Ncs.Count) { return; } string title1 = Ncs[x_index].get_title(); string title2 = Ncs[y_index].get_title(); int psm1_index = (int)Psm_hash[title1]; int psm2_index = (int)Psm_hash[title2]; PSM psm1 = MainW.psms[psm1_index]; PSM psm2 = MainW.psms[psm2_index]; PlotModel model0 = display_TwoMS2(psm1, psm2); Model_Window mw = new Model_Window(model0, psm2.Title + "-" + psm1.Title); mw.Show(); }; return(model); }
public Heatmap(string title, string xTitle, string yTitle, double[,] data) : base(title) { var model = new PlotModel { Title = title, }; OxyPalette palette = OxyPalettes.Hot(200); var colorAxis = new LinearColorAxis { InvalidNumberColor = OxyColors.Gray, Position = AxisPosition.Right, Palette = palette }; model.Axes.Add(colorAxis); var xAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = xTitle }; model.Axes.Add(xAxis); var yAxis = new LinearAxis { Title = yTitle }; model.Axes.Add(yAxis); var series = new HeatMapSeries { X0 = 0, X1 = 1, Y0 = 0, Y1 = 1, FontSize = .2 }; int width = data.GetLength(0); int height = data.GetLength(1); series.Data = new double[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { series.Data[i, j] = data[i, j]; } } model.Series.Add(series); Model = model; }
public static PlotModel CreateScatterPlotInvX() { var plotModel = new PlotModel(); var color_axis = new LinearColorAxis { Key = "ColorAxis", Maximum = 1, Minimum = 0, Position = AxisPosition.None }; plotModel.Axes.Add(color_axis); var customAxis = new RangeColorAxis() { Key = "customColors", Position = AxisPosition.None }; customAxis.AddRange(0, 50, OxyColors.LightGreen); customAxis.AddRange(50, 100, OxyColors.Green); customAxis.AddRange(100, 200, OxyColors.DarkGreen); customAxis.AddRange(200, 300, OxyColors.Orange); customAxis.AddRange(300, 500, OxyColors.DarkOrange); customAxis.AddRange(500, 100000, OxyColors.DarkRed); plotModel.Axes.Add(customAxis); var x_axis = new LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, ExtraGridlines = new double[] { 0 }, ExtraGridlineThickness = 1, ExtraGridlineColor = OxyColors.DimGray, StartPosition = 1, EndPosition = 0 }; plotModel.Axes.Add(x_axis); var y_axis = new LinearAxis { Position = AxisPosition.Left, ExtraGridlines = new double[] { 0 }, ExtraGridlineThickness = 1, ExtraGridlineColor = OxyColors.DimGray, StartPosition = 1, EndPosition = 0 }; plotModel.Axes.Add(y_axis); return(plotModel); }
private static PlotModel Surf2DModel(Surface2D surf) { var plotModel1 = new PlotModel { PlotType = PlotType.Cartesian, Title = surf.Title, Subtitle = surf.Subtitle, SubtitleFontSize = 10, TitleFont = "Tahoma", TitleFontSize = 12, DefaultFont = "Tahoma", IsLegendVisible = false }; var linearColorAxis1 = new LinearColorAxis { Title = surf.ZAxisTitle, Unit = surf.ZUnit, Position = AxisPosition.Right, AxisDistance = 5.0, InvalidNumberColor = OxyColors.Transparent, Palette = OxyPalettes.Jet(256) }; plotModel1.Axes.Add(linearColorAxis1); var linearAxis1 = new LinearAxis { MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139), MajorGridlineStyle = LineStyle.Solid, MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139), MinorGridlineStyle = LineStyle.Solid, Position = AxisPosition.Bottom, Title = surf.XAxisTitle, Unit = surf.XUnit }; plotModel1.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis { MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139), MajorGridlineStyle = LineStyle.Solid, MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139), MinorGridlineStyle = LineStyle.Solid, Title = surf.YAxisTitle, Unit = surf.YUnit }; plotModel1.Axes.Add(linearAxis2); return(plotModel1); }
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 TwoScatterSeries() { var model = new PlotModel { Title = "Two ScatterSeries (with and without values)", Subtitle = "With values (squares), without values (triangles)" }; var colorAxis = new LinearColorAxis { Position = AxisPosition.Right, Key = "ColorAxis", Palette = OxyPalettes.Jet(30), Minimum = -1, Maximum = 1 }; model.Axes.Add(colorAxis); model.Series.Add(CreateRandomScatterSeries(50, MarkerType.Triangle, false, false, null)); model.Series.Add(CreateRandomScatterSeries(50, MarkerType.Square, false, true, colorAxis)); return(model); }
public void Initialize() { var plotModel = new PlotModel { Subtitle = $"Semanantic Link: {_parentViewModel.SemanticLink.SemanticLinkId}, Direction: {_parentViewModel.Direction.Direction}" }; var colorAxis = new LinearColorAxis { HighColor = OxyColors.Gray, LowColor = OxyColors.Black, Position = AxisPosition.Right }; plotModel.Axes.Add(colorAxis); var xAxis = new LinearAxis { Title = "Time", Unit = "s", Position = AxisPosition.Bottom }; plotModel.Axes.Add(xAxis); var yAxis = new LinearAxis { Title = "Lost Energy", Unit = "kWh" }; plotModel.Axes.Add(yAxis); var heatMapSeries1 = new HeatMapSeries { LabelFormatString = "0", X0 = _parentViewModel.ChoraleModel.MinTransitTime, X1 = _parentViewModel.ChoraleModel.MaxTransitTime, Y0 = _parentViewModel.ChoraleModel.MinLostEnegry, Y1 = _parentViewModel.ChoraleModel.MaxLostEnergy, LabelFontSize = 0.2, Data = _parentViewModel.ChoraleModel.Data }; plotModel.Series.Add(heatMapSeries1); PlotModel = plotModel; _parentViewModel.ProgressBarVisibility = System.Windows.Visibility.Collapsed; }
// Инициализация public HeatGraph() { plotModel = new PlotModel { }; // Линия температурной карты plotModel.Axes.Add(linearColorAxis = new LinearColorAxis() { Position = AxisPosition.Top, MaximumRange = 1000, MinimumRange = 0, AbsoluteMinimum = 0, AbsoluteMaximum = 1000, IsZoomEnabled = false }); // Ось X plotModel.Axes.Add(linearAxisX = new LinearAxis() { Position = AxisPosition.Bottom, IsZoomEnabled = false }); // Ось Y plotModel.Axes.Add(linearAxisY = new LinearAxis() { Position = AxisPosition.Left, IsZoomEnabled = false }); // Температурная карта plotModel.Series.Add(heatMapSeries = new HeatMapSeries() { X0 = 0, X1 = 1000, Y0 = 0, Y1 = 1000, }); SetHeatMapData(new double[2, 2] { { 0, 0 }, { 0, 0 } }); }
public SumericsHeatPlot(HeatmapPlotValue plot) : base(plot) { var model = _model.Model; _plot = plot; model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom }); model.Axes.Add(new LinearAxis { Position = AxisPosition.Left }); _colorAxes = new LinearColorAxis { Position = AxisPosition.Right }; model.Axes.Add(_colorAxes); UpdateSeries(); UpdateProperties(); }
public static PlotModel CreateScatterPlot() { var plotModel = new PlotModel(); var color_axis = new LinearColorAxis { Key = "ColorAxis", Maximum = 1, Minimum = 0, Position = AxisPosition.None }; plotModel.Axes.Add(color_axis); var x_axis = new LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, ExtraGridlines = new double[] { 0 }, ExtraGridlineThickness = 1, ExtraGridlineColor = OxyColors.DimGray, StartPosition = 0, EndPosition = 1 }; plotModel.Axes.Add(x_axis); var y_axis = new LinearAxis { Position = AxisPosition.Left, ExtraGridlines = new double[] { 0 }, ExtraGridlineThickness = 1, ExtraGridlineColor = OxyColors.DimGray, StartPosition = 0, EndPosition = 1 }; plotModel.Axes.Add(y_axis); return(plotModel); }
/// <summary> /// Create the plot. /// </summary> /// <returns>Plot created.</returns> private ViewResolvingPlotModel CreatePlot() { ViewResolvingPlotModel temp = new ViewResolvingPlotModel(); //temp.Background = OxyColors.Black; // Color Legend var linearColorAxis1 = new LinearColorAxis(); linearColorAxis1.HighColor = OxyColors.Black; linearColorAxis1.LowColor = OxyColors.Black; linearColorAxis1.Palette = OxyPalettes.Jet(64); linearColorAxis1.Position = AxisPosition.Right; linearColorAxis1.Minimum = CurrentMinValue; linearColorAxis1.Maximum = CurrentMaxValue; linearColorAxis1.Key = COLOR_LEGEND_KEY; temp.Axes.Add(linearColorAxis1); // Bottom Axis // Ensembles var linearAxis2 = new LinearAxis(); linearAxis2.Position = AxisPosition.Bottom; linearAxis2.Unit = "Ensembles"; linearAxis2.Key = "Ensembles"; temp.Axes.Add(linearAxis2); // Left axis in Bins _binAxis = CreatePlotAxis(AxisPosition.Left, "bins"); _binAxis.AxisChanged += BinAxis_AxisChanged; _binAxis.Key = "BinAxis"; temp.Axes.Add(_binAxis); // Left axis in Meters next to bins _depthAxis = CreatePlotAxis(AxisPosition.Left, "meters", 2); _depthAxis.Key = "DepthAxis"; temp.Axes.Add(_depthAxis); return(temp); }
public void TestSimpleCreation() { var plotModel1 = new PlotModel { PlotType = PlotType.Cartesian, Subtitle = "Interpolated, cartesian axes", Title = "HeatMapSeries" }; var palette = OxyPalettes.Hot(200); var linearColorAxis1 = new LinearColorAxis { InvalidNumberColor = OxyColors.Gray, Position = AxisPosition.Right, Palette = palette }; plotModel1.Axes.Add(linearColorAxis1); var linearAxis1 = new LinearAxis { Position = AxisPosition.Bottom }; plotModel1.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis(); plotModel1.Axes.Add(linearAxis2); var heatMapSeries1 = new HeatMapSeries { X0 = 0.0, X1 = 1.0, Y0 = 0.0, Y1 = 1.0, FontSize = .2, Data = new Double[2, 3] }; //heatMapSeries1.LabelFontSize = 0.2; heatMapSeries1.Data[0, 0] = 0; heatMapSeries1.Data[0, 1] = 10.2; heatMapSeries1.Data[0, 2] = 20.4; heatMapSeries1.Data[1, 0] = 0.1; heatMapSeries1.Data[1, 1] = 0.3; heatMapSeries1.Data[1, 2] = 0.2; plotModel1.Series.Add(heatMapSeries1); var svg = new SvgExporter(); var svgString = svg.ExportToString(plotModel1); var xml = new XmlDocument(); xml.LoadXml(svgString); var x = SvgDocument.Open(xml); // Svg.SvgDocument(); var bmp = x.Draw(); bmp.Save(GetPath(HEATMAP_RESULTS_FOLDER_BASE + "testbmp.jpg")); var encoder = new PngPlotModelEncoder(); encoder.SaveImage(plotModel1, GetPath(HEATMAP_RESULTS_FOLDER_BASE + "mine.png")); }
public void TestLcmsWarpAlignment(string path1, string path2, string svgPath) { // Convert relative paths to absolute paths path1 = GetPath(path1); path2 = GetPath(path2); svgPath = GetPath(HEATMAP_RESULTS_FOLDER_BASE + svgPath); var aligner = new LcmsWarpFeatureAligner(new LcmsWarpAlignmentOptions()); var isosFilterOptions = new DeconToolsIsosFilterOptions(); var baselineMs = UmcLoaderFactory.LoadMsFeatureData(path1, isosFilterOptions); var aligneeMs = UmcLoaderFactory.LoadMsFeatureData(path2, isosFilterOptions); var finder = FeatureFinderFactory.CreateFeatureFinder(FeatureFinderType.TreeBased); var tolerances = new FeatureTolerances { FragmentationWindowSize = .5, Mass = 13, DriftTime = .3, Net = .01 }; var options = new LcmsFeatureFindingOptions(tolerances) { MaximumNetRange = .002 }; var baseline = finder.FindFeatures(baselineMs, options, null); var alignee = finder.FindFeatures(aligneeMs, options, null); var data = aligner.Align(baseline, alignee); var plotModel1 = new PlotModel { Subtitle = "Interpolated, cartesian axes", Title = "HeatMapSeries" }; var palette = OxyPalettes.Hot(200); var linearColorAxis1 = new LinearColorAxis { InvalidNumberColor = OxyColors.Gray, Position = AxisPosition.Right, Palette = palette }; plotModel1.Axes.Add(linearColorAxis1); // linearColorAxis1. var linearAxis1 = new LinearAxis { Position = AxisPosition.Bottom }; plotModel1.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis(); plotModel1.Axes.Add(linearAxis2); var heatMapSeries1 = new HeatMapSeries { X0 = 0, X1 = 1, Y0 = 0, Y1 = 1, FontSize = .2 }; var scores = data.HeatScores; var width = scores.GetLength(0); var height = scores.GetLength(1); heatMapSeries1.Data = new double[width, height]; for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { heatMapSeries1.Data[i, j] = Convert.ToDouble(scores[i, j]); } } plotModel1.Series.Add(heatMapSeries1); var svg = new SvgExporter(); var svgString = svg.ExportToString(plotModel1); using (var writer = File.CreateText(svgPath + ".svg")) { writer.Write(svgString); } }
/// <summary> /// Initializes a new instance of the ErrorMapViewModel class. /// </summary> /// <param name="dialogService"> /// The dialog Service. /// </param> public ErrorMapViewModel(IDialogService dialogService) { this.dialogService = dialogService; plotModel = new ViewResolvingPlotModel { Title = "Error Map", PlotAreaBackground = OxyColors.DimGray }; selectedPeakDataPoints = new IList <PeakDataPoint> [0]; minimumIonIntensity = 0; ShouldCombineChargeStates = true; TableShouldIncludeUnmatched = false; // Init x axis xAxis = new LinearAxis { Title = "Amino Acid", Position = AxisPosition.Top, AbsoluteMinimum = 0, Minimum = 0, MajorTickSize = 0, MinorStep = 2, Angle = -90, MinorTickSize = 10, MaximumPadding = 0, FontSize = 10 }; plotModel.Axes.Add(xAxis); // Init Y axis yAxis = new LinearAxis { Title = "Ion Type", Position = AxisPosition.Left, AbsoluteMinimum = 0, Minimum = 0, MajorStep = 1.0, MajorTickSize = 0, MinorStep = 0.5, MinorTickSize = 20, MaximumPadding = 0, FontSize = 10 }; plotModel.Axes.Add(yAxis); // Init Color axis var minColor = OxyColors.Navy; var medColor = OxyColors.White; var maxColor = OxyColors.DarkRed; colorAxis = new LinearColorAxis { Title = "Error", Position = AxisPosition.Right, AxisDistance = -0.5, AbsoluteMinimum = 0, Palette = OxyPalette.Interpolate(1000, minColor, medColor, maxColor), Minimum = -1 * IcParameters.Instance.ProductIonTolerancePpm.GetValue(), Maximum = IcParameters.Instance.ProductIonTolerancePpm.GetValue(), AbsoluteMaximum = IcParameters.Instance.ProductIonTolerancePpm.GetValue(), LowColor = OxyColors.DimGray, }; plotModel.Axes.Add(colorAxis); this.WhenAnyValue(x => x.ShouldCombineChargeStates).Subscribe(_ => UpdateNow()); this.WhenAnyValue(x => x.TableShouldIncludeUnmatched).Subscribe(_ => UpdateNow()); // Save As Image Command requests a file path from the user and then saves the error map as an image SaveAsImageCommand = ReactiveCommand.Create(SaveAsImageImpl); SaveDataTableCommand = ReactiveCommand.Create(SaveDataTableImpl); UpdateNowCommand = ReactiveCommand.Create(UpdateNow); ZoomOutCommand = ReactiveCommand.Create(ZoomOutPlot); }
/// <summary> /// Starts the calculation of the time development of the wavefunction under given parameters. /// As starting wave function it is either used the ground state wave function, if calculated before /// or a default one, or another one, if the double BEC checkbox is selected. /// </summary> private void button1_Click(object sender, EventArgs e) { getParams(); //read-out of the parameters // Initialization of the GPE solver, transferring the read-out parameters gpe = new GPESolver(mass, anzahl, sclength, wx, wr); double[] normedPsi = new double[gpe.psi.Length]; //Creation of the array for |Ψ|² //Plot of the trap potential, that is shown during the calculation of the time-evolution calculation plotV.Points.Clear(); // Deletes previous data points from the data series //Creation of the new data series for the plot of the potential for (int k = 0; k < gpe.psi.Length; k++) { plotV.Points.Add(new DataPoint(gpe.X[k], gpe.V[k])); } potModel.Series.Clear(); // Deletes previous data series from the plotmodel potModel.Series.Add(plotV); // Adds new data series to the plotmodel this.plot1.Model = potModel; // Shows the potential plot // Preparation of the time-dependent plot // Creation of the data grid for the time-dependent plot of |Ψ|² heatPsi.X0 = gpe.X[0]; // set xmin heatPsi.X1 = gpe.X[gpe.xSteps - 1]; // set xmax heatPsi.Y0 = 0; heatPsi.Y1 = gpe.deltaT * tsteps; //set the height of the plot heatPsi.Interpolate = true; //switch on color gradient //Creation of two color scales, using the 'Jet-palette' LinearColorAxis cAxis = new LinearColorAxis(); cAxis.Palette = OxyPalettes.Jet(100); LinearColorAxis cAxisC = new LinearColorAxis(); cAxisC.Palette = OxyPalettes.Jet(100); ColorBarModelE.Series.Clear(); this.ColorBar.Model = ColorBarModelE; //Prevents bug with colorbar if time evolution is selected before starting calculation. Reason unknown. timeModel.Axes.Add(cAxis); // Adding the color axis ColorBarModel.Axes.Add(cAxisC); double[,] dataMap = new double[gpe.psi.Length, tsteps / 100]; //Initializing data array for time-dependent plot double[,] ColorMap = new double[10, 10000]; //Initializing data array for color bar Stopwatch Stopwatch1 = new Stopwatch(); // Initialisation of the stopwatch Stopwatch1.Start(); // Start of the stopwatch //deciding which method to use for the time-development-calculation, //if there is no method chosen, Bit-Reverse is used string method; if (FFTCheckBox.Checked) { method = "CT"; } else if (DFTCheckBox.Checked) { method = "DFT"; } else if (bitReverse.Checked) { method = "BR"; } else { method = "BR"; } // The starting wave function is created, either using the default one (see GPESolver) or the ground state // is calculated, or the double BEC function is used with the offset chosen in the GUI ComplexNumber[] psiStart = (ComplexNumber[])gpe.psi.Clone(); if (getgroundstate.Checked) { gpe.getGroundState(); } else if (DBECCheckBox.Checked) { offsetDBEC = Convert.ToInt32(OffsetDBECTextBox.Text); gpe.getDPsi(offsetDBEC); } int writeOut = 0; for (int i = 0; i < tsteps; i++) { // Calculation of Ψ(t) using the split-step-fourier method using the chosen algorithm for the FFT gpe.splitStepFourier(method); // Writing every 100th calculated value into the plot array if (i == writeOut) { for (int k = 0; k < gpe.psi.Length; k++) { dataMap[k, i / 100] = Math.Pow(gpe.psi[k].Norm(), 2); } writeOut += 100; } } Stopwatch1.Stop(); // Stops the time after calculation LaufzeitTextBox.Text = Convert.ToString(Stopwatch1.ElapsedMilliseconds); // Shows runtime in textbox listBox1.Items.Insert(0, method + "-FFT:" + " " + Convert.ToString(Stopwatch1.ElapsedMilliseconds) + "ms" + " Timesteps" + tsteps.ToString()); // Adds runtime, used method and number of time steps to listbox maxColor = OxyPlot.ArrayExtensions.Max2D(dataMap); //@David ich weiß leider nicht so richtig was das macht for (int k = 0; k < 10000; k++) { for (int l = 0; l < 10; l++) { ColorMap[l, k] = maxColor * k / 10000; } } // Creation of the data grid for the display of the colorbar ColorBarSeries.X0 = 0; //set xmin ColorBarSeries.X1 = 10; //set xmax ColorBarSeries.Y0 = 0; //set height of the colorbar ColorBarSeries.Y1 = maxColor; ColorBarSeries.Interpolate = true; //switch on color gradient //Preparing Oxyplot heatPsi.Data = dataMap; // Write calculated data into plotarray ColorBarSeries.Data = ColorMap; // Write calculated data into plotarray timeModel.Series.Clear(); timeModel.Series.Add(heatPsi); // Add plotarray to plotmodel // Add the recent data series to the color bar model ColorBarModel.Series.Clear(); ColorBarModel.Series.Add(ColorBarSeries); //Calculating |Ψ|² and |Ψstart|² and writing it into the plot arrays for (int k = 0; k < gpe.psi.Length; k++) { normedPsi[k] = Math.Pow(gpe.psi[k].Norm(), 2); plotPsi.Points.Add(new DataPoint(gpe.X[k], normedPsi[k])); normedPsi[k] = Math.Pow(psiStart[k].Norm(), 2); plotPsiStart.Points.Add(new DataPoint(gpe.X[k], normedPsi[k])); } // Deleting the old series and add the new ones myModel.Series.Clear(); myModel.Series.Add(plotPsiStart); myModel.Series.Add(plotPsi); // this.plot1.Model = timeModel; // Show the time-dependent plot this.ColorBar.Model = ColorBarModel; // Show the created color bar this.ColorBar.Visible = true; // Make the color bar visible this.shiftPotButton.Enabled = true; // The shift potential button is usable now //Energy = ETC.Hamilton(gpe.psi, gpe.V, gpe.deltaX, PhysConst.hbar, mass, gpe.g1D); //EnergieTextBox.Text = Convert.ToString(Energy); //Energie in TextBox }
private async void createPlotModel() { await Task.Run(() => { this.dataTable = DatabaseAccesserEcolog.GetResult(createQuery()); }); calculateEnergyParameter(); calculateTimeParameter(); var plotModel = new PlotModel(); plotModel.Subtitle = "SemananticLink: " + semantciLink.Semantics + ", Direction: " + direction.Direction; plotModel.Title = "Semantic Matrix"; var linearColorAxis = new LinearColorAxis(); linearColorAxis.HighColor = OxyColors.Gray; linearColorAxis.LowColor = OxyColors.Black; linearColorAxis.Position = AxisPosition.Right; plotModel.Axes.Add(linearColorAxis); var linearAxis1 = new LinearAxis(); linearAxis1.Title = "Time"; linearAxis1.Unit = "s"; linearAxis1.Position = AxisPosition.Bottom; plotModel.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis(); linearAxis2.Title = "Lost Energy"; linearAxis2.Unit = "kWh"; plotModel.Axes.Add(linearAxis2); var heatMapSeries1 = new HeatMapSeries(); heatMapSeries1.LabelFormatString = "0"; heatMapSeries1.X0 = minExcludedTime; heatMapSeries1.X1 = maxExcludedTime; heatMapSeries1.Y0 = minExcludedEnergy; heatMapSeries1.Y1 = maxExcludedEnergy; heatMapSeries1.LabelFontSize = 0.2; heatMapSeries1.Data = new Double[classNumber + 1, classNumber + 1]; int count = 0; // for debug double preTimeLevel = 0; double currentTimeLevel = minExcludedTime; for (int i = 0; i < classNumber + 1; i++) { double preEnergyLevel = 0; double currentEnergyLevel = minExcludedEnergy; for (int j = 0; j < classNumber + 1; j++) { heatMapSeries1.Data[i, j] = dataTable.AsEnumerable() .Where(x => x.Field <double>("SumLostEnergy") > preEnergyLevel) .Where(x => x.Field <double>("SumLostEnergy") <= currentEnergyLevel) .Where(x => x.Field <int>("TIME") > preTimeLevel) .Where(x => x.Field <int>("TIME") <= currentTimeLevel).Count(); count += (int)heatMapSeries1.Data[i, j]; if (j == 0) { preEnergyLevel = minExcludedEnergy; } else { preEnergyLevel += classWidthEnergy; } currentEnergyLevel += classWidthEnergy; } if (i == 0) { preTimeLevel = minExcludedTime; } else { preTimeLevel += classWidthTime; } currentTimeLevel += classWidthTime; } plotModel.Series.Add(heatMapSeries1); this.ProgressBarVisibility = System.Windows.Visibility.Collapsed; this.PlotModel = plotModel; }
public void TestMsFeatureScatterPlot(string path1, string path2, string pngPath) { // Convert relative paths to absolute paths path1 = GetPath(path1); path2 = GetPath(path2); pngPath = GetPath(pngPath); var fiOutput = new FileInfo(pngPath); var didirectory = fiOutput.Directory; if (didirectory == null) { throw new DirectoryNotFoundException(pngPath); } if (!didirectory.Exists) { didirectory.Create(); } var aligner = new LcmsWarpFeatureAligner(new LcmsWarpAlignmentOptions()); var isosFilterOptions = new DeconToolsIsosFilterOptions(); var baselineMs = UmcLoaderFactory.LoadMsFeatureData(path1, isosFilterOptions); var aligneeMs = UmcLoaderFactory.LoadMsFeatureData(path2, isosFilterOptions); var finder = FeatureFinderFactory.CreateFeatureFinder(FeatureFinderType.TreeBased); var tolerances = new FeatureTolerances { FragmentationWindowSize = .5, Mass = 13, DriftTime = .3, Net = .01 }; var options = new LcmsFeatureFindingOptions(tolerances); options.MaximumNetRange = .002; var baseline = finder.FindFeatures(baselineMs, options, null); var alignee = finder.FindFeatures(aligneeMs, options, null); var alignmentResults = aligner.Align(baseline, alignee); var plotModel1 = new PlotModel { Subtitle = "Interpolated, cartesian axes", Title = "HeatMapSeries" }; var palette = OxyPalettes.Hot(200); var linearColorAxis1 = new LinearColorAxis { InvalidNumberColor = OxyColors.Gray, Position = AxisPosition.Right, Palette = palette }; plotModel1.Axes.Add(linearColorAxis1); // linearColorAxis1. var linearAxis1 = new LinearAxis { Position = AxisPosition.Bottom }; plotModel1.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis(); plotModel1.Axes.Add(linearAxis2); var heatMapSeries1 = new HeatMapSeries { X0 = 0, X1 = 1, Y0 = 0, Y1 = 1, FontSize = .2 }; var scores = alignmentResults.HeatScores; var width = scores.GetLength(0); var height = scores.GetLength(1); heatMapSeries1.Data = new double[width, height]; var seriesData = heatMapSeries1.Data; for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { seriesData[i, j] = Convert.ToDouble(scores[i, j]); } } plotModel1.Series.Add(heatMapSeries1); var svg = new SvgExporter(); var svgString = svg.ExportToString(plotModel1); var xml = new XmlDocument(); xml.LoadXml(svgString); var x = SvgDocument.Open(xml); // Svg.SvgDocument(); var bmp = x.Draw(); bmp.Save(pngPath); var heatmap = HeatmapFactory.CreateAlignedHeatmap(alignmentResults.HeatScores, false); var netHistogram = HistogramFactory.CreateHistogram(alignmentResults.NetErrorHistogram, "NET Error", "NET Error"); var massHistogram = HistogramFactory.CreateHistogram(alignmentResults.MassErrorHistogram, "Mass Error", "Mass Error (ppm)"); var baseName = Path.Combine(didirectory.FullName, Path.GetFileNameWithoutExtension(fiOutput.Name)); var encoder = new SvgEncoder(); PlotImageUtility.SaveImage(heatmap, baseName + "_heatmap.svg", encoder); PlotImageUtility.SaveImage(netHistogram, baseName + "_netHistogram.svg", encoder); PlotImageUtility.SaveImage(massHistogram, baseName + "_massHistogram.svg", encoder); }
public void InitPlot() { this.CScanPalette = new LinearColorAxis { Position = AxisPosition.Right, Maximum = 100, Minimum = 0 }; this.DScanPalette = new LinearColorAxis { Position = AxisPosition.Right, Maximum = 100, Minimum = 0 }; CScanSeries = new HeatMapSeries { X0 = 0, X1 = 100, Y0 = 0, Y1 = 100, Interpolate = true, RenderMethod = HeatMapRenderMethod.Bitmap, // Data = CScanRawData }; DScanSeries = new HeatMapSeries { X0 = 0, X1 = 100, Y0 = 0, Y1 = 100, Interpolate = true, RenderMethod = HeatMapRenderMethod.Bitmap, // Data = DScanRawData }; CScanYaxis = new LinearAxis { Minimum = 0, Maximum = 100, MinimumPadding = 0, MaximumPadding = 0, Angle = 45, Position = AxisPosition.Left }; DScanYaxis = new LinearAxis { Minimum = 0, Maximum = 100, MinimumPadding = 0, MaximumPadding = 0, Angle = 45, Position = AxisPosition.Left }; CScanXaxis = new LinearAxis { Minimum = 0, Maximum = 100, MinimumPadding = 0, MaximumPadding = 0, Angle = 45, Position = AxisPosition.Bottom }; DScanXaxis = new LinearAxis { Minimum = 0, Maximum = 100, MinimumPadding = 0, MaximumPadding = 0, Angle = 45, Position = AxisPosition.Bottom }; }
private static ScatterSeries CreateRandomScatterSeries(int n, MarkerType markerType, bool setSize, bool setValue, LinearColorAxis colorAxis) { var s1 = new ScatterSeries { MarkerType = markerType, MarkerSize = 6, ColorAxisKey = colorAxis != null ? colorAxis.Key : "nix" }; var random = new Random(13); for (int i = 0; i < n; i++) { var p = new ScatterPoint((random.NextDouble() * 2.2) - 1.1, random.NextDouble()); if (setSize) { p.Size = (random.NextDouble() * 5) + 5; } if (setValue) { p.Value = (random.NextDouble() * 2.2) - 1.1; } s1.Points.Add(p); } return(s1); }
/// <summary> /// Initializes a new instance of the <see cref="FeatureMapViewModel"/> class. /// </summary> /// <param name="dialogService">Dialog service for opening dialogs from the view model.</param> public FeatureMapViewModel(IDialogService dialogService = null) { this.dialogService = dialogService ?? new DialogService(); ms2SeriesDictionary = new Dictionary <string, ScatterSeries>(); ShowFoundIdMs2 = false; ShowFoundUnIdMs2 = false; IsLinearAbundanceAxis = false; IsLogarithmicAbundanceAxis = true; FeatureSize = 0.1; FeatureSelectedCommand = ReactiveCommand.Create(FeatureSelectedImplementation); // Save As Image Command requests a file path from the user and then saves the spectrum plot as an image SaveAsImageCommand = ReactiveCommand.Create(SaveAsImageImplementation); // Initialize color axes. const int numColors = 5000; featureColorAxis = new LinearColorAxis // Color axis for features { Title = "Abundance", Position = AxisPosition.Right, Palette = OxyPalette.Interpolate(numColors, IcParameters.Instance.FeatureColors), }; colorDictionary = new ProteinColorDictionary(); ms2ColorAxis = new LinearColorAxis // Color axis for ms2s { Key = "ms2s", Position = AxisPosition.None, Palette = colorDictionary.OxyPalette, Minimum = 1, Maximum = colorDictionary.OxyPalette.Colors.Count, AxisTitleDistance = 1 }; // Initialize x and y axes. yaxis = new LinearAxis { Position = AxisPosition.Left, Title = "Monoisotopic Mass", StringFormat = "0.###" }; xaxis = new LinearAxis { Position = AxisPosition.Bottom, Title = "Retention Time", StringFormat = "0.###", }; // Change size of scan highlight annotation when feature map x and y axes are zoomed or panned. var isInternalChange = false; xaxis.AxisChanged += (o, e) => { XMinimum = Math.Round(xaxis.ActualMinimum, 3); XMaximum = Math.Round(xaxis.ActualMaximum, 3); if (!isInternalChange && highlight != null && highlight.TextPosition.X >= xaxis.ActualMinimum && highlight.TextPosition.X <= xaxis.ActualMaximum && highlight.TextPosition.Y >= yaxis.ActualMinimum && highlight.TextPosition.Y <= yaxis.ActualMaximum) { var x = highlight.TextPosition.X; isInternalChange = true; highlight.MinimumX = x - ((xaxis.ActualMaximum - xaxis.ActualMinimum) * HighlightScale * 0.5); highlight.MaximumX = x + ((xaxis.ActualMaximum - xaxis.ActualMinimum) * HighlightScale * 0.5); } isInternalChange = false; }; yaxis.AxisChanged += (o, e) => { YMinimum = Math.Round(yaxis.ActualMinimum, 3); YMaximum = Math.Round(yaxis.ActualMaximum, 3); if (!isInternalChange && highlight != null && highlight.TextPosition.X >= xaxis.ActualMinimum && highlight.TextPosition.X <= xaxis.ActualMaximum && highlight.TextPosition.Y >= yaxis.ActualMinimum && highlight.TextPosition.Y <= yaxis.ActualMaximum) { var y = highlight.TextPosition.Y; isInternalChange = true; highlight.MinimumY = y - ((yaxis.ActualMaximum - yaxis.ActualMinimum) * HighlightScale); highlight.MaximumY = y + ((yaxis.ActualMaximum - yaxis.ActualMinimum) * HighlightScale); } isInternalChange = false; }; // Initialize feature map. FeatureMap = new PlotModel { Title = "Feature Map" }; FeatureMap.MouseDown += FeatureMapMouseDown; FeatureMap.Axes.Add(featureColorAxis); FeatureMap.Axes.Add(ms2ColorAxis); FeatureMap.Axes.Add(xaxis); FeatureMap.Axes.Add(yaxis); // When ShowNotFoundMs2 changes, update the NotFoundMs2 series this.WhenAnyValue(x => x.ShowFoundUnIdMs2) .Where(_ => FeatureMap != null && ms2SeriesDictionary.ContainsKey(string.Empty)) .Subscribe(showFoundUnIdMs2 => { ms2SeriesDictionary[string.Empty].IsVisible = showFoundUnIdMs2; FeatureMap.InvalidatePlot(true); }); // When ShowFoundIdMs2 changes, update all ms2 series this.WhenAnyValue(x => x.ShowFoundIdMs2) .Where(_ => FeatureMap != null) .Subscribe(showFoundMs2 => { foreach (var protein in ms2SeriesDictionary.Keys.Where(key => !string.IsNullOrWhiteSpace(key))) { ms2SeriesDictionary[protein].IsVisible = showFoundMs2; } FeatureMap.InvalidatePlot(true); }); this.WhenAnyValue(x => x.IsLinearAbundanceAxis) .Subscribe(isLinearAbundanceAxis => IsLogarithmicAbundanceAxis = !isLinearAbundanceAxis); this.WhenAnyValue(x => x.IsLogarithmicAbundanceAxis) .Subscribe(isLogarithmicAbundanceAxis => IsLinearAbundanceAxis = !isLogarithmicAbundanceAxis); // Update plot axes when FeaturePlotXMin, YMin, XMax, and YMax change this.WhenAnyValue(x => x.XMinimum, x => x.XMaximum) .Throttle(TimeSpan.FromSeconds(1), RxApp.TaskpoolScheduler) .Where(x => !xaxis.ActualMinimum.Equals(x.Item1) || !xaxis.ActualMaximum.Equals(x.Item2)) .Subscribe( x => { xaxis.Zoom(x.Item1, x.Item2); FeatureMap.InvalidatePlot(false); }); this.WhenAnyValue(y => y.YMinimum, x => x.YMaximum) .Throttle(TimeSpan.FromSeconds(1), RxApp.TaskpoolScheduler) .Where(y => !yaxis.ActualMinimum.Equals(y.Item1) || !yaxis.ActualMaximum.Equals(y.Item2)) .Subscribe( y => { yaxis.Zoom(y.Item1, y.Item2); FeatureMap.InvalidatePlot(false); }); // When SelectedPrSm is changed, update highlighted prsm on plot this.WhenAnyValue(x => x.SelectedPrSm) .Where(selectedPrSm => selectedPrSm != null) .Subscribe(selectedPrSm => { SetHighlight(selectedPrSm); FeatureMap.InvalidatePlot(true); SelectedPrSm.WhenAnyValue(x => x.Scan) .Subscribe(scan => { SetHighlight(selectedPrSm); FeatureMap.InvalidatePlot(true); }); }); var propMon = this.WhenAnyValue(x => x.IsLinearAbundanceAxis, x => x.FeatureSize, x => x.Features) .Select(x => featureColorAxis.Title = x.Item1 ? "Abundance" : "Abundance (Log10)"); var colorMon = IcParameters.Instance.WhenAnyValue(x => x.IdColors, x => x.Ms2ScanColor, x => x.FeatureColors) .Select(x => { var colorList = new List <OxyColor> { Capacity = x.Item1.Length + 1 }; colorList.Add(x.Item2); colorList.AddRange(x.Item1); colorDictionary.SetColors(colorList); ms2ColorAxis.Palette = colorDictionary.OxyPalette; featureColorAxis.Palette = OxyPalette.Interpolate(numColors, x.Item3); return(string.Empty); }); // Link two observables to a single throttle and action. propMon.Merge(colorMon).Throttle(TimeSpan.FromSeconds(1), RxApp.TaskpoolScheduler).Subscribe(x => BuildPlot()); }
public static PlotModel ConfusionMatrix() { // Example provided by Pau Climent Pérez // See also http://en.wikipedia.org/wiki/Confusion_matrix var data = new double[3, 3]; data[0, 0] = 1; data[1, 1] = 0.8; data[1, 2] = 0.2; data[2, 2] = 1; // I guess this is where the confusion comes from? data = data.Transpose(); string[] cat1 = { "class A", "class B", "class C" }; var model = new PlotModel { Title = "Confusion Matrix" }; var palette = OxyPalette.Interpolate(50, OxyColors.White, OxyColors.Black); var lca = new LinearColorAxis { Position = AxisPosition.Right, Palette = palette, HighColor = OxyColors.White, LowColor = OxyColors.White }; model.Axes.Add(lca); var axis1 = new CategoryAxis { Position = AxisPosition.Top, Title = "Actual class" }; axis1.Labels.AddRange(cat1); model.Axes.Add(axis1); // We invert this axis, so that they look "symmetrical" var axis2 = new CategoryAxis { Position = AxisPosition.Left, Title = "Predicted class" }; axis2.Labels.AddRange(cat1); axis2.Angle = -90; axis2.StartPosition = 1; axis2.EndPosition = 0; model.Axes.Add(axis2); var hms = new HeatMapSeries { Data = data, Interpolate = false, LabelFontSize = 0.25, X0 = 0, X1 = data.GetLength(1) - 1, Y0 = 0, Y1 = data.GetLength(0) - 1, }; model.Series.Add(hms); return(model); }
private void btnPreview_Click(object sender, EventArgs e) { updateNote(); //get layers List <double> layers = new List <double>(); if (layerPercentflag) { int num = (int)(layerPercent * spotMaps.Count / 100); layers = spotMaps.OrderByDescending(s => s.NominalEnergy).Select(s => s.NominalEnergy).Take(num).ToList(); } else if (layerThresholdflag) { layers = spotMaps.Where(s => s.NominalEnergy > layerThreshold).Select(s => s.NominalEnergy).ToList(); } else { layers = spotMaps.Select(s => s.NominalEnergy).ToList(); } List <SpotMap> ssm = Utility.splitSpotMaps(spotMaps, thresholdMU, MUMWratio, layers, energyUp, smallMUcap, energyUpflag, energyDownflag); int totalSpots = ssm.Sum(s => s.ScanSpotNumber); double maxMU = ssm.Max(s => s.MeterWeights.Max()) * this.MUMWratio; txtStatistic.Text = initText + string.Format(" After split total {0} layers, Total {1} spot and Max MU is {2:0.000}.", ssm.Count, totalSpots, maxMU); txtStatistic.Text += ("\nUse PgUP PgDn to ZOOM, use right mouse click and drag to PAN."); panel3.Controls.Clear(); int ht = 0; foreach (SpotMap sm in ssm) { var pm = new PlotModel { Title = string.Format("{0:0.000}MeV", sm.NominalEnergy), TitleFontSize = 10 }; var coloraxis = new LinearColorAxis { Key = "ColorAxis", Position = AxisPosition.None, Minimum = ssm.Min(ss => ss.MeterWeights.Min()), Maximum = ssm.Max(ss => ss.MeterWeights.Max()) }; pm.Axes.Add(coloraxis); var s = new ScatterSeries { MarkerType = MarkerType.Circle, MarkerSize = 2, MarkerStrokeThickness = 0, ColorAxisKey = "ColorAxis", TrackerFormatString = "\nX: {2:0.###}\nY: {4:0.###}\nMU: {Tag}" }; for (int i = 0; i < sm.ScanSpotNumber; i++) { s.Points.Add(new ScatterPoint(sm.X[i], sm.Y[i], double.NaN, sm.MeterWeights[i] * this.MUMWratio, (sm.MeterWeights[i] * this.MUMWratio).ToString("0.###"))); } pm.Series.Add(s); var pv = new PlotView(); pv.Model = pm; pm.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -200, Maximum = 200 }); pm.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -200, Maximum = 200 }); pv.Location = new System.Drawing.Point(0, ht); pv.Size = new System.Drawing.Size(360, 400); ht += pv.Size.Height; panel3.Controls.Add(pv); } }
private PlotModel CreatePlotModel(string propertyName) { string title = null; switch (propertyName) { case "ConvertLoss": title = "Convert loss"; break; case "AirResistance": title = "Air resistance"; break; case "RollingResistance": title = "Rolling resistance"; break; case "RegeneLoss": title = "Regene loss"; break; } var model = new PlotModel { Subtitle = title, PlotMargins = new OxyThickness(double.NaN, double.NaN, 80, double.NaN) }; var colorAxis = new LinearColorAxis { HighColor = OxyColors.Gray, LowColor = OxyColors.Black, Position = AxisPosition.Right, MajorStep = 0.02, Minimum = 0, Maximum = _maximum, Unit = "kWh", AxisTitleDistance = 0 }; model.Axes.Add(colorAxis); var xAxis = new LinearAxis { Title = "Transit time", Unit = "s", Position = AxisPosition.Bottom }; model.Axes.Add(xAxis); var yAxis = new LinearAxis { Title = "Lost energy", Unit = "kWh" }; model.Axes.Add(yAxis); var scatterSeries = new ScatterSeries(); foreach (var datum in _graphData) { scatterSeries.Points.Add(new ScatterPoint(datum.TransitTime, datum.LostEnergy) { Value = (float)typeof(GraphDatum).GetProperty(propertyName).GetValue(datum) }); } model.Series.Add(scatterSeries); return(model); }
private void CreateHeatMapModel(double[,] ballUpdates = null) { double[,] ballPositions; if (ballUpdates == null) { ballPositions = new double[Configuration.HeatMapDimensions.Item1, Configuration.HeatMapDimensions.Item2]; for (var i = 0; i < ballPositions.GetLength(0); ++i) { for (var j = 0; j < ballPositions.GetLength(1); ++j) { ballPositions[i, j] = double.NaN; } } } else { ballPositions = ((HeatMapSeries)HeatMapModel.Series.First()).Data; for (var i = 0; i < ballPositions.GetLength(0); ++i) { for (var j = 0; j < ballPositions.GetLength(1); ++j) { if (double.IsNaN(ballPositions[i, j]) && Math.Abs(ballUpdates[i, j] - 0d) > 1E-5) { ballPositions[i, j] = ballUpdates[i, j]; } else { ballPositions[i, j] += ballUpdates[i, j]; } } } } var heatMapSeries = new HeatMapSeries { X0 = 0d, X1 = 1d, Y0 = 0d, Y1 = 1d, Data = ballPositions, }; var linearColorAxis = new LinearColorAxis { InvalidNumberColor = OxyColors.Transparent }; var linearXAxis = new LinearAxis { Position = AxisPosition.Bottom }; var linearYAxis = new LinearAxis(); var plotModel = new PlotModel(); plotModel.Series.Add(heatMapSeries); plotModel.Axes.Add(linearColorAxis); plotModel.Axes.Add(linearXAxis); plotModel.Axes.Add(linearYAxis); plotModel.PlotAreaBorderThickness = 0; plotModel.Axes.Execute(a => a.IsAxisVisible = false); HeatMapModel = plotModel; }