Ejemplo n.º 1
0
        void Plot2DMultipleAxes()
        {
            // Example 2D plot:
            // First curve:
            Plot2DCurve curve1 = plotMultipleAxes.AddLine(new double[] { 1.2, 1.3, 2.8, 5.6, 1.9, -5.9 });
            curve1.Stroke = Brushes.Blue; curve1.StrokeThickness = 1.5; curve1.MarkersType = MarkersType.Square;
            // Second curve:
            int nPoints = 2000;
            double[] x = new double[nPoints];
            double[] y = new double[nPoints];
            Random rand = new Random();
            for (int i = 0; i < nPoints; ++i)
            {
                x[i] = i * 10.0 / (double)nPoints;
                y[i] = Math.Sin(x[i]) + 0.1 * Math.Sin(x[i] * 100);
            }
            Plot2DCurve curve2 = new Plot2DCurve(new Curve(x, y)) { QuickLine = "r-" };
            plotMultipleAxes.Children.Add(curve2);
            // Third curve:
            Plot2DCurve curve3 = new Plot2DCurve(new Curve(new double[] { 1, 3, 1.5, 7 }, new double[] { 4.5, 9.0, 3.2, 4.5 })) { StrokeThickness = 3.0, Stroke = Brushes.Green };
            curve3.QuickLine = "o";
            curve3.MarkersFill = Brushes.Blue;
            curve3.Title = "Test3";
            //curve3.QuickStrokeDash = QuickStrokeDash.Dash;
            plotMultipleAxes.Children.Add(curve3);
            // Can use Direct2D acceleration, but requires DirectX10 (Windows 7)
            //plotMultipleAxes.UseDirect2D = true; 
            //plotMultipleAxes.EqualAxes = true;

            // If you want to lose the gradient background:
            //plotMultipleAxes.Legend.Background = Brushes.White;
            //plotMultipleAxes.BackgroundPlot = Brushes.White;

            // Additional labels:
            //plotMultipleAxes.BottomLabel.Text = "Bottom label";
            //plotMultipleAxes.LeftLabel.Text = "Left label";
            plotMultipleAxes.FontSize = 14;
            plotMultipleAxes.Axes.XAxes[0].AxisLabel.Text = "Innermost X Axis";
            plotMultipleAxes.Axes.YAxes[0].AxisLabel.Text = "Innermost Y Axis";
            XAxis xAxisOuter = new XAxis(); YAxis yAxisOuter = new YAxis();
            xAxisOuter.AxisLabel.Text = "Added X Axis";
            yAxisOuter.AxisLabel.Text = "Added Y Axis";
            plotMultipleAxes.Axes.XAxes.Add(xAxisOuter);
            plotMultipleAxes.Axes.YAxes.Add(yAxisOuter);
            yAxisOuter.Position = YAxisPosition.Left;
            plotMultipleAxes.Axes.XAxes[0].FontStyle = plotMultipleAxes.Axes.YAxes[0].FontStyle = FontStyles.Oblique;
            //curve3.XAxis = xAxisOuter;
            curve3.YAxis = yAxisOuter;
            // Other alyout options to try:
            //plotMultipleAxes.Axes.EqualAxes = new AxisPair(plot1.Axes.XAxes.Bottom, plot1.Axes.YAxes.Left);
            //plotMultipleAxes.Axes.SetAxesEqual();
            //plotMultipleAxes.Axes.Height = 100;
            //plotMultipleAxes.Axes.Width = 500;
            //plotMultipleAxes.Axes.MinAxisMargin = new Thickness(200, 0, 0, 0);
            plotMultipleAxes.Axes.XAxes.Top.TickLength = 5;
            plotMultipleAxes.Axes.YAxes.Left.TickLength = 5;

            xAxisOuter.Min = 6.5e-5;
            xAxisOuter.Max = 7.3e-3;
            xAxisOuter.AxisType = AxisType.Log;
            plotMultipleAxes.Children.Add(new Plot2DCurve(new Curve(new double[] { 0.01, 10 }, new double[] { 5, 6 })) { XAxis = xAxisOuter });
            plotMultipleAxes.UseDirect2D = false;
        }
Ejemplo n.º 2
0
 public static MatrixTransform GraphToCanvasLinear(XAxis xAxis, YAxis yAxis)
 {
     return new MatrixTransform(xAxis.Scale, 0, 0, -yAxis.Scale, -xAxis.Offset - xAxis.AxisPadding.Lower, yAxis.Offset + yAxis.AxisTotalLength - yAxis.AxisPadding.Upper);
 }
Ejemplo n.º 3
0
 public AxisPair(XAxis xAxis, YAxis yAxis)
 {
     XAxis = xAxis; YAxis = yAxis;
 }
Ejemplo n.º 4
0
        public Axes2D(PlotPanel plotPanel)
        {
            this.plotPanel = plotPanel;
            frame = new AxesFrame();
            frame.SetValue(Grid.ZIndexProperty, 300);
            // note that individual axes have index of 200
            plotPanel.Children.Add(frame);

            xAxisBottom = new XAxis();
            xAxisBottom.SetValue(XAxis.XAxisPositionProperty, XAxisPosition.Bottom);
            //
            xAxes = new XAxis2DCollection(plotPanel);
            xAxes.Add(xAxisBottom); 
            //
            yAxisLeft = new YAxis();
            yAxisLeft.SetValue(YAxis.YAxisPositionProperty, YAxisPosition.Left);
            //
            yAxes = new YAxis2DCollection(plotPanel);
            yAxes.Add(yAxisLeft); 
            //
            UpdateTicks();        
        }
Ejemplo n.º 5
0
        protected virtual void OnHostChanged(PlotPanel host)
        {
            if (host == null)
            {
                xAxis = null; yAxis = null;
                return;
            }
            // Update axis to default if null or it it does not belong to the new plot.
            if ((xAxis == null) || (!host.Axes.XAxes.Contains(xAxis)))
            {
                xAxis = host.Axes.XAxes.Bottom;
            }

            if ((yAxis == null) || (!host.Axes.YAxes.Contains(yAxis)))
            {
                yAxis = host.Axes.YAxes.Left;
            }
        }
Ejemplo n.º 6
0
        public Axes2D(PlotPanel plotPanel)
        {
            this.plotPanel = plotPanel;
            frame = new AxesFrame();
            frame.SetValue(Grid.ZIndexProperty, 300);
            // note that individual axes have index of 200
            plotPanel.Children.Add(frame);

            xAxisBottom = new XAxis();
            xAxisBottom.SetValue(XAxis.XAxisPositionProperty, XAxisPosition.Bottom);
            xAxisTop = new XAxis();
            xAxisTop.SetValue(XAxis.XAxisPositionProperty, XAxisPosition.Top);
            //
            xAxes = new XAxis2DCollection(plotPanel);
            xAxes.Add(xAxisBottom); xAxes.Add(xAxisTop);
            xAxis = xAxisBottom;
            xAxisTop.LabelsVisible = false;
            xAxisTop.TicksVisible = true;
            xAxisTop.GridLines.Visibility = Visibility.Collapsed;
            xAxisTop.BindToAxis(xAxisBottom);
            //
            yAxisLeft = new YAxis();
            yAxisLeft.SetValue(YAxis.YAxisPositionProperty, YAxisPosition.Left);
            yAxisRight = new YAxis();
            yAxisRight.SetValue(YAxis.YAxisPositionProperty, YAxisPosition.Right);
            //
            yAxes = new YAxis2DCollection(plotPanel);
            yAxes.Add(yAxisLeft); yAxes.Add(yAxisRight);
            yAxis = yAxisLeft;
            yAxisRight.LabelsVisible = false;
            yAxisRight.TicksVisible = true;
            yAxisRight.GridLines.Visibility = Visibility.Collapsed;
            yAxisRight.BindToAxis(yAxisLeft);
            //
            UpdateTicks();        
        }