/// <summary> /// /// </summary> public TremorTool() { InitializeComponent(); _syncContext = SynchronizationContext.Current; grid_advancedSettingsHolder.Visibility = Visibility.Hidden; grid_graphHolder.Visibility = Visibility.Hidden; combobox_nodeSelect.Items.Clear(); Nodes.UpdateAvailableSensors(); foreach (string sensor in Nodes.COM_Ports) combobox_nodeSelect.Items.Add(sensor); if (!combobox_nodeSelect.Items.IsEmpty) combobox_nodeSelect.SelectedIndex = 0; // Makes the plot. Plot = new OxyPlot.Wpf.PlotView(); Plot.Model = new PlotModel(); Plot.Model.PlotType = PlotType.XY; Plot.Model.Background = OxyColor.FromRgb(255, 255, 255); //Plot.Dock = DockStyle.Fill; groupBox_graph.Content = Plot; //Plot.Model.TextColor = OxyColor.FromRGB(0, 0, 0); //Our graph data is filled with zeros for now. for (int i = 0; i < 10; i++) { graphData[0, i] = 0; fLine.Points.Add(new DataPoint(i, graphData[0, i])); graphData[1, i] = 0; aLine.Points.Add(new DataPoint(i, graphData[1, i])); } // add Series and Axis to plot model OxyPlot.Axes.LinearAxis fAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Left, 0.0, 15.0); //Makes the axes. OxyPlot.Axes.LinearAxis aAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Right, 0.0, 20.0); fAxis.Key = "Frequency"; //Sets the key for the and amplitude. aAxis.Key = "Amplitude"; fAxis.Title = "Frequency (Hz)"; aAxis.Title = "Amplitude (?)"; fLine.YAxisKey = fAxis.Key; //Assigns the key to the series. aLine.YAxisKey = aAxis.Key; Plot.Model.Series.Add(fLine); //Adds the data for the frequency. Plot.Model.Series.Add(aLine); //Adds the data for the amplitude. Plot.Model.Axes.Add(new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Bottom, 0.0, 10.0)); //Adds the X axis. Plot.Model.Axes.Add(fAxis); //Adds the Y Axis for the frequency Plot.Model.Axes.Add(aAxis); //Adds the Y Axis for the amplitude }
}//end private void stop_registration_button_Click(object sender, RoutedEventArgs e) //********************************************************************************************************************************** private void draw_charts_of_elementary_cycles(registrator_cls registrator, OxyPlot.Wpf.PlotView plotview, PlotModel aux_plotmodel) { int counter = 0; LineSeries[] graphs = new LineSeries[registrator.list_of_cycles.Count]; foreach (registrator_cls.single_cycle_cls item in registrator.list_of_cycles) { //mean_cycle_chart0.rewind_graph(); graphs[counter] = new LineSeries(); graphs[counter].Color = OxyColor.FromRgb(0, 255, 0); if (Math.Abs(item.length - registrator.Base_length_value) <= 1) { for (int i = 0; i < registrator.base_length_value; i++) { // draw stroke of cycle double value; if ((item.length < registrator.Base_length_value) && (i >= item.length)) { value = registrator.Storage.get_data(item.start_index + item.length - 1); } else { value = registrator.Storage.get_data(item.start_index + i); } //mean_cycle_chart0.add_stroke(value, 0); graphs[counter].Points.Add(new DataPoint(i * 0.025, value)); } aux_plotmodel.Series.Add(graphs[counter]); counter++; } } //plotview.Model = aux_plotmodel; //plotview.UpdateLayout(); }
void draw_smoothed_mean_cycle_chart(registrator_cls registrator, OxyPlot.Wpf.PlotView plotview, PlotModel aux_plotmodel) { LineSeries mean_graph = new LineSeries(); mean_graph.Color = OxyColor.FromRgb(255, 0, 0); double value, old_value; old_value = registrator.get_filtered_mean_cycle_data(0); for (int i = 0; i < registrator.base_length_value; i++) { // draw stroke of mean cycle graph value = registrator.get_smoothed_cycle_data(i); if (!Double.IsNaN(value)) { mean_graph.Points.Add(new DataPoint(i * 0.025, value)); } else { mean_graph.Points.Add(new DataPoint(i * 0.025, old_value)); } } aux_plotmodel.Series.Add(mean_graph); plotview.Model = aux_plotmodel; plotview.UpdateLayout(); }
/// <summary> /// Construct a new instance of the class. /// </summary> /// <param name="title">The plot title.</param> /// <param name="results">The data to plot.</param> public Plot(string title, List <List <double> > results) { // set up plot model var plotModel = new OxyPlot.PlotModel(); plotModel.Title = title; // set up axes and colors plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Title = "Error" }); plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Epochs" }); var colors = new OxyPlot.OxyColor[] { OxyPlot.OxyColors.Blue, OxyPlot.OxyColors.Green, OxyPlot.OxyColors.Red, OxyPlot.OxyColors.Black }; // set up lines for (int i = 0; i < results.Count; i++) { var lineSeries = new OxyPlot.Series.LineSeries(); lineSeries.ItemsSource = results[i].Select((value, index) => new OxyPlot.DataPoint(index, value)); lineSeries.Title = string.Format("KFold {0}/{1}", i + 1, results.Count); //lineSeries.Color = colors[i]; plotModel.Series.Add(lineSeries); } var plotView = new OxyPlot.Wpf.PlotView(); plotView.Model = plotModel; Title = title; Content = plotView; }
/// <summary> /// Creates a line plot. The data X value is the X-coordinate, the data Y value is the Y-coordinate. /// </summary> public LinePlot(OxyPlot.Wpf.PlotView oxyPlotView, IEnumerable <Datum> data, OxyColor?lineColor = null, double lineThickness = 2, string xAxisLabel = null, string yAxisLabel = null, string chartTitle = null, string chartSubtitle = null, bool addToLegend = true, string seriesTitle = null, bool refreshAfterAddingData = true) : base(oxyPlotView) { AddLinePlot(data, lineColor, lineThickness, xAxisLabel, yAxisLabel, chartTitle, chartSubtitle, addToLegend, seriesTitle, refreshAfterAddingData); }
public static void TestLinePlot() { // the PlotView is a WPF control that's created in the .xaml code OxyPlot.Wpf.PlotView examplePlotView = new OxyPlot.Wpf.PlotView(); // just some example data to plot var datapoint1 = new Datum(0, 1); var datapoint2 = new Datum(2, 3); // create the plot Plot plot = new LinePlot(examplePlotView, new List <Datum> { datapoint1, datapoint2 }, lineColor: OxyColors.Blue); // check to make sure the data was plotted Assert.That(plot.Model.Series.Count == 1); var series = plot.Model.Series[0]; var points = ((LineSeries)series).Points; Assert.That(points.Count == 2); Assert.That(points[0].X == 0); Assert.That(points[0].Y == 1); Assert.That(points[1].X == 2); Assert.That(points[1].Y == 3); Assert.That(((LineSeries)series).ActualColor == OxyColors.Blue); }
InlineObjectElement CreateUIElement(int length, int offset, CurveInfo curveInfo) { if (base.IsPrinting) { BitmapImage bitmap = CurveViewCache.Instance.LoadImage(Document, offset, curveInfo); if (bitmap != null) { var image = new System.Windows.Controls.Image(); image.Source = bitmap; image.Width = bitmap.PixelWidth; image.Height = bitmap.PixelHeight; image.Cursor = Cursors.Arrow; // Pass the length of the match to the 'documentLength' parameter // of InlineObjectElement. return(new InlineObjectElement(length, image)); } } else { OxyPlot.Wpf.PlotView view = CurveViewCache.Instance.LoadPlotView(Document, offset, curveInfo); if (view != null) { return(new InlineObjectElement(length, view)); } } return(null); }
public static void TestScatterPlot() { // the PlotView is a WPF control that's created in the .xaml code OxyPlot.Wpf.PlotView examplePlotView = new OxyPlot.Wpf.PlotView(); // just some example data to plot var datapoint1 = new Datum(0, 1); var datapoint2 = new Datum(2, 3); // create the plot Plot plot = new ScatterPlot(examplePlotView, new List <Datum> { datapoint1, datapoint2 }, markerColor: OxyColors.Blue, xAxisLabel: "xAxis", yAxisLabel: "yAxis", chartTitle: "title", chartSubtitle: "subtitle"); // check to make sure the data was plotted Assert.That(plot.Model.Series.Count == 1); var series = plot.Model.Series[0]; var points = ((ScatterSeries)series).ActualPoints; Assert.That(points.Count == 2); Assert.That(points[0].X == 0); Assert.That(points[0].Y == 1); Assert.That(points[1].X == 2); Assert.That(points[1].Y == 3); Assert.That(((ScatterSeries)series).ActualMarkerFillColor == OxyColors.Blue); Assert.That(plot.Model.Title == "title"); Assert.That(plot.Model.Subtitle == "subtitle"); Assert.That(plot.Model.Axes[0].Title == "xAxis"); Assert.That(plot.Model.Axes[1].Title == "yAxis"); }
public PlotWindow(List <List <double> > results) { var plotModel = new OxyPlot.PlotModel(); plotModel.Title = "Mean Absolute Validation Error Per Fold"; plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Title = "Error" }); plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Epochs" }); var colors = new OxyPlot.OxyColor[] { OxyPlot.OxyColors.Blue, OxyPlot.OxyColors.Green, OxyPlot.OxyColors.Red, OxyPlot.OxyColors.Black }; for (int row = 0; row < results.Count; row++) { var lineSeries = new OxyPlot.Series.LineSeries(); lineSeries.ItemsSource = results[row].Select((value, index) => new OxyPlot.DataPoint(index, value)); lineSeries.Title = string.Format("Fold {0}/{1}", row + 1, results.Count); lineSeries.Color = colors[row]; plotModel.Series.Add(lineSeries); } var plotView = new OxyPlot.Wpf.PlotView(); plotView.Model = plotModel; Title = "Chart"; Content = plotView; }
/// <summary> /// Creates a scatter plot. The data X value is the X-coordinate, the data Y value is the Y-coordinate. /// </summary> public ScatterPlot(OxyPlot.Wpf.PlotView oxyPlotView, IEnumerable <Datum> data, OxyColor?markerColor = null, double markerSize = 3, string xAxisLabel = null, string yAxisLabel = null, string chartTitle = null, string chartSubtitle = null, bool addToLegend = true, string seriesTitle = null, bool refreshAfterAddingData = true) : base(oxyPlotView) { AddScatterPlot(data, markerColor, markerSize, xAxisLabel, yAxisLabel, chartTitle, chartSubtitle, addToLegend, seriesTitle, refreshAfterAddingData); }
public DataLoading() { TestCommand = new RelayCommand(() => ShowActualPoints()); PlotModel = new PlotModel(); X = new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Minimum = 1, Maximum = 5 }; Y = new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, IsPanEnabled = false }; FirstSeries = new OxyPlot.Series.LineSeries(); SecondSeries = new OxyPlot.Series.LineSeries(); FirstLoad(); PlotModel.Axes.Add(X); PlotModel.Axes.Add(Y); OxyPlot.Wpf.PlotView PV = new OxyPlot.Wpf.PlotView(); PlotModel.Axes[0].AxisChanged += (o, e) => { double LastPoint = (from y in FirstSeries.Points select y.X).Min(); ShowActuals(LastPoint); }; }
public PeptideSpectrumMatchPlot(OxyPlot.Wpf.PlotView plotView, Canvas sequenceDrawingCanvas, PsmFromTsv psm, MsDataScan scan, List <MatchedFragmentIon> matchedFragmentIons, bool annotateProperties = true, LibrarySpectrum librarySpectrum = null) : base(plotView) { Model.Title = string.Empty; Model.Subtitle = string.Empty; SpectrumMatch = psm; Scan = scan; SequenceDrawingCanvas = sequenceDrawingCanvas; SequenceDrawingCanvas.Height = 60; sequenceDrawingCanvas.Width = 600; ClearCanvas(SequenceDrawingCanvas); DrawSpectrum(); AnnotateBaseSequence(psm.BaseSeq, psm.FullSequence, 10, matchedFragmentIons); AnnotateMatchedIons(isBetaPeptide: false, matchedFragmentIons); if (annotateProperties) { AnnotateProperties(); } ZoomAxes(matchedFragmentIons); if (librarySpectrum != null) { AnnotateLibraryIons(isBetaPeptide: false, librarySpectrum.MatchedFragmentIons); } RefreshChart(); }
public TemperaturePlotWindow(float[] temperature) { var plotModel = new OxyPlot.PlotModel(); plotModel.Title = "Temperature"; plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Title = "Celcius" }); //plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Epochs" }); var labels = new string[] { "Temperature" }; var colors = new OxyPlot.OxyColor[] { OxyPlot.OxyColors.Blue }; var lineSeries = new OxyPlot.Series.LineSeries(); lineSeries.ItemsSource = temperature.Select((value, index) => new OxyPlot.DataPoint(index, value)); lineSeries.Title = labels[0]; lineSeries.Color = colors[0]; plotModel.Series.Add(lineSeries); var plotView = new OxyPlot.Wpf.PlotView(); plotView.Model = plotModel; Content = plotView; }
public PlotWindow(List <List <double> > results) { var plotModel = new OxyPlot.PlotModel(); plotModel.Title = "Training and Validation Accuracy"; plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Title = "Accuracy", Minimum = 0, Maximum = 1 }); plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Epochs" }); var labels = new string[] { "Training", "Validation" }; var colors = new OxyPlot.OxyColor[] { OxyPlot.OxyColors.Blue, OxyPlot.OxyColors.Green }; for (int row = 0; row < results.Count; row++) { var lineSeries = new OxyPlot.Series.LineSeries(); lineSeries.ItemsSource = results[row].Select((value, index) => new OxyPlot.DataPoint(index, value)); lineSeries.Title = labels[row]; lineSeries.Color = colors[row]; plotModel.Series.Add(lineSeries); } var plotView = new OxyPlot.Wpf.PlotView(); plotView.Model = plotModel; Title = "Chart"; Content = plotView; }
public static void TestBarPlot() { // the PlotView is a WPF control that's created in the .xaml code OxyPlot.Wpf.PlotView examplePlotView = new OxyPlot.Wpf.PlotView(); // just some example data to plot var datapoint1 = new Datum(0, label: "category1"); var datapoint2 = new Datum(2, label: "category2"); // create the plot Plot plot = new BarPlot(examplePlotView, new List <Datum> { datapoint1, datapoint2 }, fillColor: OxyColors.Blue); // check to make sure the data was plotted Assert.That(plot.Model.Series.Count == 1); var series = plot.Model.Series[0]; var points = ((ColumnSeries)series).Items; Assert.That(points.Count == 2); Assert.That(points[0].Value == 0); Assert.That(points[1].Value == 2); Assert.That(((ColumnSeries)series).ActualFillColor == OxyColors.Blue); }
/// <summary> /// Creates a bar plot. The data X value is the height of the bar, and the data label is the X-axis label under the bar. /// </summary> public BarPlot(OxyPlot.Wpf.PlotView oxyPlotView, IEnumerable <Datum> data, OxyColor?borderColor = null, OxyColor?fillColor = null, double borderThickness = 1, string xAxisLabel = null, string yAxisLabel = null, string chartTitle = null, string chartSubtitle = null, bool addToLegend = true, string seriesTitle = null, bool refreshAfterAddingData = true) : base(oxyPlotView) { AddBarPlot(data, borderColor, fillColor, borderThickness, xAxisLabel, yAxisLabel, chartTitle, chartSubtitle, addToLegend, seriesTitle, refreshAfterAddingData); }
public GraphsVm(FlightdataModel data, OxyPlot.Wpf.PlotView pv_features, OxyPlot.Wpf.PlotView pvCorr, OxyPlot.Wpf.PlotView pvReg) { //initizlize dat model. this.data = data; //setting up the pv this.pv_features = pv_features; this.pvCor = pvCorr; this.pvReg = pvReg; //creating a stopwatch,to set up the time. this.clock = new Stopwatch(); clock.Start(); //initizling plotmodel and list. this.plotModelFeatures = new PlotModel(); this.plotModelCor = new PlotModel(); this.plotModelReg = new PlotModel(); this.featuresList = new List <float>(); this.corrList = new List <float>(); //usual mvvm propertychanged setup. this.data.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e) { NotifyPropertyChanged("VM_" + e.PropertyName); }; //at every line property change - build the graph after 450 ms passed. this.data.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e) { //if currentline has been changed,and there more then 500 ms passed - set up the graph again for cleaner view. if (clock.ElapsedMilliseconds > 450 + lastStopTime && e.PropertyName == "CurrentLine" && VM_ChosenFeature != null && VM_ChosenCorr != null) { //plot1 this.VM_PlotModelFeatures.Series.Clear(); FeatureList = this.data.FeatureChosenValues(); SetUpModel(VM_PlotModelFeatures); LoadData(featuresList, VM_PlotModelFeatures); this.pv_features.InvalidatePlot(true); //plot2 Updatecorr(VM_ChosenFeature); corrList = data.FeatureChosenCorrValues(); this.VM_PlotModelCor.Series.Clear(); SetUpModel(VM_PlotModelCor); LoadData(corrList, VM_PlotModelCor); this.pvCor.InvalidatePlot(true); //plot3 this.VM_PlotModelReg.Series.Clear(); SetUpModel(VM_PlotModelReg); LoadRegData(FeatureList, corrList, VM_PlotModelReg); this.pvReg.InvalidatePlot(true); this.lastStopTime = clock.ElapsedMilliseconds; } }; }
public static void TestMetaDrawLoadingWithWeirdFileNames() { // test loading when the file has a periods, commas, spaces in the name string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestMetaDrawLoadingWithWeirdFileNames"); string proteinDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\smalldb.fasta"); string spectraFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\SmallCalibratible_Yeast.mzML"); string pathWithPeriodInIt = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\S.m,al. lC,al.ib r.at,i ble_Ye.ast.mzML"); File.Copy(spectraFile, pathWithPeriodInIt, true); spectraFile = pathWithPeriodInIt; Directory.CreateDirectory(outputFolder); // run search task var searchtask = new SearchTask(); searchtask.RunTask(outputFolder, new List <DbForTask> { new DbForTask(proteinDatabase, false) }, new List <string> { spectraFile }, ""); var psmFile = Path.Combine(outputFolder, @"AllPSMs.psmtsv"); // load results into metadraw var metadrawLogic = new MetaDrawLogic(); metadrawLogic.PsmResultFilePaths.Add(psmFile); metadrawLogic.SpectraFilePaths.Add(pathWithPeriodInIt); var errors = metadrawLogic.LoadFiles(true, true); Assert.That(!errors.Any()); Assert.That(metadrawLogic.FilteredListOfPsms.First().FileNameWithoutExtension == "S.m,al. lC,al.ib r.at,i ble_Ye.ast"); var plotView = new OxyPlot.Wpf.PlotView(); var canvas = new Canvas(); var parentChildScanPlotsView = new ParentChildScanPlotsView(); // plot PSM metadrawLogic.DisplaySpectrumMatch(plotView, canvas, metadrawLogic.FilteredListOfPsms.First(), parentChildScanPlotsView, out errors); Assert.That(errors == null || !errors.Any()); // export to PDF metadrawLogic.ExportToPdf(plotView, canvas, new List <PsmFromTsv> { metadrawLogic.FilteredListOfPsms.First() }, parentChildScanPlotsView, outputFolder, out errors); Assert.That(!errors.Any()); // clean up resources metadrawLogic.CleanUpResources(); // delete output File.Delete(pathWithPeriodInIt); Directory.Delete(outputFolder, true); }
public void Init(OxyPlot.Wpf.PlotView _chart, System.Windows.Controls.ListView _list) { chart = _chart; list = _list; pm = new PlotModel(); pm = LineSeries(); chart.Model = pm; }
private void MakePlotView() { m_PlotView = new OxyPlot.Wpf.PlotView(); m_PlotView.Model = m_CurvePlotModel; m_PlotView.Width = WIDTH; m_PlotView.Height = HEIGHT; m_PlotView.ActualController.UnbindMouseWheel(); m_PlotView.Cursor = Cursors.Arrow; }
/// <summary> /// /// </summary> public TremorDetectionWindow() { InitializeComponent(); _syncContext = SynchronizationContext.Current; grid_advancedSettingsHolder.Visibility = Visibility.Hidden; grid_graphHolder.Visibility = Visibility.Hidden; combobox_nodeSelect.Items.Clear(); Nodes.UpdateAvailableSensors(); foreach (string sensor in Nodes.Ports) { combobox_nodeSelect.Items.Add(sensor); } if (!combobox_nodeSelect.Items.IsEmpty) { combobox_nodeSelect.SelectedIndex = 0; } // Makes the plot. Plot = new OxyPlot.Wpf.PlotView(); Plot.Model = new PlotModel(); Plot.Model.PlotType = PlotType.XY; Plot.Model.Background = OxyColor.FromRgb(255, 255, 255); //Plot.Dock = DockStyle.Fill; groupBox_graph.Content = Plot; //Plot.Model.TextColor = OxyColor.FromRGB(0, 0, 0); //Our graph data is filled with zeros for now. for (int i = 0; i < 10; i++) { graphData[0, i] = 0; fLine.Points.Add(new DataPoint(i, graphData[0, i])); graphData[1, i] = 0; aLine.Points.Add(new DataPoint(i, graphData[1, i])); } // add Series and Axis to plot model OxyPlot.Axes.LinearAxis fAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Left, 0.0, 15.0); //Makes the axes. OxyPlot.Axes.LinearAxis aAxis = new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Right, 0.0, 20.0); fAxis.Key = "Frequency"; //Sets the key for the and amplitude. aAxis.Key = "Amplitude"; fAxis.Title = "Frequency (Hz)"; aAxis.Title = "Amplitude (?)"; fLine.YAxisKey = fAxis.Key; //Assigns the key to the series. aLine.YAxisKey = aAxis.Key; Plot.Model.Series.Add(fLine); //Adds the data for the frequency. Plot.Model.Series.Add(aLine); //Adds the data for the amplitude. Plot.Model.Axes.Add(new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Bottom, 0.0, 10.0)); //Adds the X axis. Plot.Model.Axes.Add(fAxis); //Adds the Y Axis for the frequency Plot.Model.Axes.Add(aAxis); //Adds the Y Axis for the amplitude }
public static void TestMetaDrawErrors() { string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestMetaDrawErrors"); string proteinDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\smalldb.fasta"); string spectraFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\SmallCalibratible_Yeast.mzML"); Directory.CreateDirectory(outputFolder); // run search task var searchtask = new SearchTask(); searchtask.RunTask(outputFolder, new List <DbForTask> { new DbForTask(proteinDatabase, false) }, new List <string> { spectraFile }, ""); var psmFile = Path.Combine(outputFolder, @"AllPSMs.psmtsv"); // load results into metadraw (skipping spectra file, to produce an error msg) var metadrawLogic = new MetaDrawLogic(); metadrawLogic.PsmResultFilePaths.Add(psmFile); // this should produce an error because an expected spectra file is not present var errors = metadrawLogic.LoadFiles(loadSpectra: true, loadPsms: true); Assert.That(errors.Any()); Assert.That(!metadrawLogic.FilteredListOfPsms.Any()); // this should not produce an error because we said not to load spectra errors = metadrawLogic.LoadFiles(loadSpectra: false, loadPsms: true); Assert.That(!errors.Any()); var psmsFromTsv = PsmTsvReader.ReadTsv(psmFile, out var warnings); var plotView = new OxyPlot.Wpf.PlotView(); var canvas = new Canvas(); var parentChildScanPlotsView = new ParentChildScanPlotsView(); // plotting PSM should produce an error because spectra are not loaded metadrawLogic.DisplaySpectrumMatch(plotView, canvas, psmsFromTsv.First(), parentChildScanPlotsView, out errors); Assert.That(errors.Any()); // export to PDF should produce an error because spectra are not loaded metadrawLogic.ExportToPdf(plotView, canvas, new List <PsmFromTsv> { psmsFromTsv.First() }, parentChildScanPlotsView, outputFolder, out errors); Assert.That(errors.Any()); // clean up resources metadrawLogic.CleanUpResources(); // delete output Directory.Delete(outputFolder, true); }
private void CscanView_SizeChanged(object sender, SizeChangedEventArgs e) { OxyPlot.Wpf.PlotView p = (sender as OxyPlot.Wpf.PlotView); if (isDataLoaded) { double windowRatio = p.Model.PlotArea.Width / p.Model.PlotArea.Height; WindowWidth = 100; WindowHeight = 100 / windowRatio; } }
/// <summary> /// 初始化单曲线显示 /// </summary> /// <param name="plot">显示模型</param> /// <param name="pv">显示视图</param> /// <param name="title">标题</param> /// <param name="strLabel">图例</param> /// <param name="colors">颜色</param> private void InitSingleCurve(ref PlotCurve plot, OxyPlot.Wpf.PlotView pv, string title, string strLabel, OxyColor colors) { try { plot = new PlotCurve(strLabel, colors, title); pv.Model = plot.GetModel(); } catch (Exception ex) { MessageBox.Show(ex.Message, "初始化显示plot" + title); } }
public override void OnApplyTemplate() { DataGrid = this.GetTemplateChild("DataGrid") as DataGrid; DataGrid.ItemsSource = dataTable?.DefaultView; var buttonSaveToCsv = this.GetTemplateChild("Save_To_Csv") as Button; buttonSave = this.GetTemplateChild("Save") as Button; buttonLoad = this.GetTemplateChild("Load") as Button; sliderItemsControl = this.GetTemplateChild("SliderItemsControl") as SliderItemsControl; Diagram = this.GetTemplateChild("Diagram") as OxyPlot.Wpf.PlotView; Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => buttonSave.Click += h, h => buttonSave.Click -= h) .WithLatestFrom <EventPattern <RoutedEventArgs>, object, Action>(regressorChanges, (a, b) => (b as ISaveLoad).Save) .Subscribe(_ => _.Invoke()); Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => buttonLoad.Click += h, h => buttonLoad.Click -= h) .WithLatestFrom <EventPattern <RoutedEventArgs>, object, Action>(regressorChanges, (a, b) => (b as ISaveLoad).Load) .Subscribe(_ => _.Invoke()); if (buttonSaveToCsv != null) { Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => buttonSaveToCsv.Click += h, h => buttonSaveToCsv.Click -= h) .WithLatestFrom <EventPattern <RoutedEventArgs>, object, Task <bool> >(trainDataViewChanges, (a, b) => SaveToCsv(dataTable)) .Subscribe(async _ => await _); } var xxx = Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => sliderItemsControl.ValueChanged += h, h => sliderItemsControl.ValueChanged -= h) .WithLatestFrom(regressorChanges, (a, b) => new Action(() => SliderItemsControl_ValueChanged(a.EventArgs, b))) .Buffer(TimeSpan.FromMilliseconds(100)) .ObserveOnDispatcher() .Subscribe(_ => _.LastOrDefault()?.Invoke()); regressorChanges.CombineLatest(testDataViewChanges, AddPoints).Subscribe(async _ => { await _; }); Diagram.Model = CreatePlotModel(); Diagram.Model.InvalidatePlot(true); // sliderItemsControl.ValueChanged +=(a,s SliderItemsControl_ValueChanged; }
public Matrix_Model ( int plot_index, string[] op_tit, List <ScatterSeries> list_matrix_series, List <ScatterSeries> list_work_series, OxyPlot.Wpf.PlotView matrix2D_work_plot, Work_Model work_model ) { Title = op_tit[plot_index]; index = plot_index; IsLegendVisible = false; PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1); PlotMargins = new OxyThickness(0, 0, 0, 0); Padding = new OxyThickness(5); Background = OxyColors.White; SelectionColor = OxyColors.Crimson; Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, TickStyle = OxyPlot.Axes.TickStyle.None, //MajorGridlineStyle = LineStyle.Dash, //MinorGridlineStyle = LineStyle.Dash, MaximumPadding = 0.1, MinimumPadding = 0.1, IsPanEnabled = false, IsZoomEnabled = false, FontSize = 0.1, SelectionMode = OxyPlot.SelectionMode.Multiple }); Axes.Add(new LinearAxis { Position = AxisPosition.Left, TickStyle = OxyPlot.Axes.TickStyle.None, //MajorGridlineStyle = LineStyle.Dash, //MinorGridlineStyle = LineStyle.Dash, MaximumPadding = 0.1, MinimumPadding = 0.1, IsPanEnabled = false, IsZoomEnabled = false, FontSize = 0.1, SelectionMode = OxyPlot.SelectionMode.Multiple }); Load_Mouse_Events(list_matrix_series, list_work_series, work_model, matrix2D_work_plot); }
private void PlotChart(Card card, Dictionary <uint, List <Quotation> > all_quotes) { OxyPlot.Wpf.PlotView plotView = new OxyPlot.Wpf.PlotView(); OxyPlot.PlotModel plot = new OxyPlot.PlotModel() { LegendPlacement = OxyPlot.LegendPlacement.Outside, LegendPosition = OxyPlot.LegendPosition.BottomCenter, LegendOrientation = OxyPlot.LegendOrientation.Horizontal }; plot.Axes.Add(new OxyPlot.Axes.DateTimeAxis()); plot.Axes.Add(new OxyPlot.Axes.LinearAxis() { Minimum = 0 }); List <DateTime> dates = new List <DateTime>(); List <double> values = new List <double>(); foreach (var provider in all_quotes) { OxyPlot.Series.LineSeries ls = new OxyPlot.Series.LineSeries() { Title = Static.Database.Instance.Providers.First(x => x.ID == provider.Key).Name, CanTrackerInterpolatePoints = false, MarkerSize = 2, MarkerType = OxyPlot.MarkerType.Circle, TrackerFormatString = "{0}\n{2:dd/MM/yyyy}\nR$ {4:F2}" }; foreach (Quotation q in provider.Value) { DateTime dt = DateTime.FromFileTimeUtc(q.Timestamp); double vl = double.Parse(q.Value); dates.Add(dt); values.Add(vl); ls.Points.Add(OxyPlot.Axes.DateTimeAxis.CreateDataPoint(dt, vl)); } plot.Series.Add(ls); } if (dates.Count > 0) { plot.Axes[0].Minimum = OxyPlot.Axes.DateTimeAxis.ToDouble(dates.Min().AddDays(-1)); plot.Axes[0].Maximum = OxyPlot.Axes.DateTimeAxis.ToDouble(dates.Max().AddDays(1)); plot.Axes[1].Maximum = values.Max() * 1.1; } plotView.Model = plot; plotGrid.Children.Clear(); plotGrid.Children.Add(plotView); }
// creates the chosen graph public void LoadLineDataGraph(int lineNumber, OxyPlot.Wpf.PlotView pv, List <float> valueList, PlotModel pm) { var lineSerie = new LineSeries() { StrokeThickness = 2, Color = OxyColors.Black, }; for (int i = 0; i < lineNumber; i++) { lineSerie.Points.Add(new DataPoint(i, valueList[i])); } //adding lineSeries to plotModel pm.Series.Add(lineSerie); }
/***Methods***/ public graphView(IClientModel c, ViewModelController vmc) { InitializeComponent(); this.vmCon = vmc; this.graphViewModel = new GraphViewModel(c, vmc, attPlot, corrPlot, LRPlot); this.DataContext = graphViewModel; StackPanel stackPanel = new StackPanel(); //creating buttons setupButtons(stackPanel); scorllButtons.Content = stackPanel; Attpv = attPlot; Corrpv = corrPlot; RegLinepv = LRPlot; Loaded += GraphView_Loaded; }
public static void TestPngExport() { // the PlotView is a WPF control that's created in the .xaml code OxyPlot.Wpf.PlotView examplePlotView = new OxyPlot.Wpf.PlotView(); // create the plot Plot plot = new ScatterPlot(examplePlotView, new List <Datum> { new Datum(0, 1), new Datum(2, 3) }); string exportPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "testPngExport.png"); plot.ExportToPng(exportPath); Assert.That(File.Exists(exportPath)); File.Delete(exportPath); }
/// <summary> /// Construct a new instance of the class. /// </summary> /// <param name="results">The data to plot.</param> public Plot(List <List <double> > results) { // set up a new plot var plotModel = new PlotModel(); plotModel.Title = "Training and Validation error"; // add x and y axis plotModel.Axes.Add( new LinearAxis() { Position = AxisPosition.Left, Title = "Classification Error" } ); plotModel.Axes.Add( new LinearAxis() { Position = AxisPosition.Bottom, Title = "Epochs" } ); // add data series var labels = new string[] { "Training", "Validation" }; var colors = new OxyColor[] { OxyColors.Blue, OxyColors.Green }; for (int row = 0; row < results.Count; row++) { var lineSeries = new LineSeries { ItemsSource = results[row].Select((value, index) => new DataPoint(index, value)), Title = labels[row], Color = colors[row] }; plotModel.Series.Add(lineSeries); } // wrap up Title = "Chart"; Content = new OxyPlot.Wpf.PlotView { Model = plotModel }; }
private void AddTrackPlot(Track track) { MelodySequence seq = track.GetMainSequence() as MelodySequence; ListBoxItem listBoxItem = new ListBoxItem(); OxyPlot.Wpf.PlotView plotView = new OxyPlot.Wpf.PlotView(); plotView.Margin = new Thickness(0, 0, 82, 10); setupTrackPlot(plotView); generateSongPlotFull(plotView.Model, seq.GeneratePlaybackInfo(0)); Grid grid = new Grid(); grid.Height = 128; grid.Children.Add(plotView); listBoxItem.Content = grid; listBoxItem.Tag = track; listBoxItem.MouseDoubleClick += listBoxItem_MouseDoubleClick; itemsBox.Items.Add(listBoxItem); }