Пример #1
0
        public static void PlotHistogram(string file_path, double[] values, int bincount, double lower_quantile, double upper_quantile)
        {
            Array.Sort(values);
            double lowerbound = ToolsMathStatistics.QuantileSorted(values, lower_quantile);
            double upperbound = ToolsMathStatistics.QuantileSorted(values, upper_quantile);

            double[] selected_values = ToolsMathCollection.Select(values, lowerbound, upperbound);
            double   stride          = (upperbound - lowerbound) / bincount;

            double[] bin_limits = new double[bincount - 1];
            bin_limits[0] = lowerbound + stride;
            for (int bin_limit_index = 1; bin_limit_index < bin_limits.Length; bin_limit_index++)
            {
                bin_limits[bin_limit_index] = bin_limits[bin_limit_index - 1] + stride;
            }

            PlotModel model = new HistrogramPlot(selected_values, bin_limits).PlotModel;

            WriteToFile(file_path, model, 800, 800);
        }
Пример #2
0
        //private class PlotShower
        //{
        //    PlotModel plot_model;

        //    public PlotShower(PlotModel plot_model)
        //    {
        //        this.plot_model = plot_model;
        //    }

        //    public void ShowPlotInWindowTread()
        //    {

        //        //Canvas canvas = new Canvas();
        //        //canvas.Width = 800;
        //        //canvas.Height = 800;
        //        //canvas.Background = System.Windows.Media.Brushes.Red;


        //        Window window = new Window();
        //        window.AllowsTransparency = false;
        //        window.WindowStyle = WindowStyle.ThreeDBorderWindow;
        //        window.Background = System.Windows.Media.Brushes.White;
        //        window.Topmost = true;
        //        window.Width = 800;
        //        window.Height = 800;
        //        window.ResizeMode = ResizeMode.CanResize;

        //        var plotModel = new PlotModel { Title = "OxyPlot Demo" };

        //        plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Bottom });
        //        plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Left, Maximum = 10, Minimum = 0 });

        //        var series1 = new OxyPlot.Wpf.LineSeries
        //        {
        //            MarkerType = MarkerType.Circle,
        //            MarkerSize = 4,
        //            MarkerStroke = System.Windows.Media.Color.FromRgb(50, 50, 50)
        //        };

        //        //series1.Points.Add(new DataPoint(0.0, 6.0));
        //        //series1.Points.Add(new DataPoint(1.4, 2.1));
        //        //series1.Points.Add(new DataPoint(2.0, 4.2));
        //        //series1.Points.Add(new DataPoint(3.3, 2.3));
        //        //series1.Points.Add(new DataPoint(4.7, 7.4));
        //        //series1.Points.Add(new DataPoint(6.0, 6.2));
        //        //series1.Points.Add(new DataPoint(8.9, 8.9));

        //        //plotModel.Series.Add(series1);


        //        PlotView plot_view = new PlotView();
        //        plot_view.Background = System.Windows.Media.Brushes.Blue;
        //        plot_view.DataContext = plotModel;
        //        plot_view.ToolTip = "oops";

        //         //plot_view.Title = "Testplotview";


        //         window.Content = plot_view;
        //        window.Show();
        //        System.Windows.Threading.Dispatcher.Run();

        //    }
        //}

        //public static void ShowPlotInWindow(PlotLine2D line_plot)
        //{
        //    ShowPlotInWindow(line_plot.PlotModel);
        //}


        //private static void ShowPlotInWindow(PlotModel plot_model)
        //{
        //    PlotShower shower = new PlotShower(plot_model);

        //    Thread tread = new Thread(shower.ShowPlotInWindowTread);
        //    tread.SetApartmentState(ApartmentState.STA);
        //    tread.Start();
        //}


        public static void PlotHistogram(string file_path)
        {
            PlotModel model = new HistrogramPlot().PlotModel;

            WriteToFile(file_path, model, 800, 800);
        }