Ejemplo n.º 1
0
            /// <summary>
            /// Returns a y-axis that is suitable for drawing the data.
            /// </summary>
            /// <returns>A suitable y-axis.</returns>
            public Axis SuggestYAxis()
            {
                double min_l;
                double max_l;
                double min_h;
                double max_h;

                if (this.rows_ == null)
                {
                    Utils.ArrayMinMax((System.Collections.IList)lowData_, out min_l, out max_l);
                    Utils.ArrayMinMax((System.Collections.IList)highData_, out min_h, out max_h);
                }
                else
                {
                    Utils.RowArrayMinMax(this.rows_, out min_l, out max_l, (string)this.lowData_);
                    Utils.RowArrayMinMax(this.rows_, out min_h, out max_h, (string)this.highData_);
                }

                Axis a = new LinearAxis( min_l, max_h );
                a.IncreaseRange( 0.08 );
                return a;
            }
Ejemplo n.º 2
0
        public void CreatePlot(InteractivePlotSurface2D plotSurface)
        {
            plotSurface.Clear();

            // draw a fine grid.
            Grid fineGrid = new Grid();
            fineGrid.VerticalGridType = Grid.GridType.Fine;
            fineGrid.HorizontalGridType = Grid.GridType.Fine;
            plotSurface.Add(fineGrid);

            const int npt = 101;
            float[] x = new float[npt];
            float[] y = new float[npt];
            float step = 0.1f;
            for (int i = 0; i < npt; ++i)
            {
                x[i] = i * step - 5.0f;
                y[i] = (float)Math.Pow(10.0, x[i]);
            }
            float xmin = x[0];
            float xmax = x[npt - 1];
            float ymin = (float)Math.Pow(10.0, xmin);
            float ymax = (float)Math.Pow(10.0, xmax);

            LinePlot lp = new LinePlot();
            lp.OrdinateData = y;
            lp.AbscissaData = x;
            lp.Pen = new Pen(Color.Red);
            plotSurface.Add(lp);

            LogAxis loga = new LogAxis(plotSurface.YAxis1);
            loga.WorldMin = ymin;
            loga.WorldMax = ymax;
            loga.AxisColor = Color.Red;
            loga.LabelColor = Color.Red;
            loga.TickTextColor = Color.Red;
            loga.LargeTickStep = 1.0f;
            loga.Label = "10^x";
            plotSurface.YAxis1 = loga;

            LinePlot lp1 = new LinePlot();
            lp1.OrdinateData = y;
            lp1.AbscissaData = x;
            lp1.Pen = new Pen(Color.Blue);
            plotSurface.Add(lp1, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Right);
            LinearAxis lin = new LinearAxis(plotSurface.YAxis2);
            lin.WorldMin = ymin;
            lin.WorldMax = ymax;
            lin.AxisColor = Color.Blue;
            lin.LabelColor = Color.Blue;
            lin.TickTextColor = Color.Blue;
            lin.Label = "10^x";
            plotSurface.YAxis2 = lin;

            LinearAxis lx = (LinearAxis)plotSurface.XAxis1;
            lx.WorldMin = xmin;
            lx.WorldMax = xmax;
            lx.Label = "x";

            //((LogAxis)plotSurface.YAxis1).LargeTickStep = 2;

            plotSurface.Title = "Mixed Linear/Log Axes";

            //plotSurface.XAxis1.LabelOffset = 20.0f;

            plotSurface.Refresh();
        }
Ejemplo n.º 3
0
        public void CreatePlot(InteractivePlotSurface2D plotSurface)
        {
            plotSurface.Clear();

            // Create a new line plot from array data via the ArrayAdapter class.
            LinePlot lp = new LinePlot();
            lp.DataSource = makeDaub(256);
            lp.Color = Color.Green;
            lp.Label = "Daubechies Wavelet"; // no legend, but still useful for copy data to clipboard.

            Grid myGrid = new Grid();
            myGrid.VerticalGridType = Grid.GridType.Fine;
            myGrid.HorizontalGridType = Grid.GridType.Coarse;
            plotSurface.Add(myGrid);

            // And add it to the plot surface
            plotSurface.Add(lp);
            plotSurface.Title = "Reversed / Upside down Daubechies Wavelet";

            // Ok, the above will produce a decent default plot, but we would like to change
            // some of the Y Axis details. First, we'd like lots of small ticks (10) between
            // large tick values. Secondly, we'd like to draw a grid for the Y values. To do
            // this, we create a new LinearAxis (we could also use Label, Log etc). Rather than
            // starting from scratch, we use the constructor that takes an existing axis and
            // clones it (values in the superclass Axis only are cloned). PlotSurface2D
            // automatically determines a suitable axis when we add plots to it (merging
            // current requirements with old requirements), and we use this as our starting
            // point. Because we didn't specify which Y Axis we are using when we added the
            // above line plot (there is one on the left - YAxis1 and one on the right - YAxis2)
            // PlotSurface2D.Add assumed we were using YAxis1. So, we create a new axis based on
            // YAxis1, update the details we want, then set the YAxis1 to be our updated one.
            LinearAxis myAxis = new LinearAxis(plotSurface.YAxis1);
            myAxis.NumberOfSmallTicks = 2;
            plotSurface.YAxis1 = myAxis;

            // We would also like to modify the way in which the X Axis is printed. This time,
            // we'll just modify the relevant PlotSurface2D Axis directly.
            plotSurface.XAxis1.WorldMax = 100.0f;

            plotSurface.PlotBackColor = Color.OldLace;
            plotSurface.XAxis1.Reversed = true;
            plotSurface.YAxis1.Reversed = true;

            // Force a re-draw of the control.
            plotSurface.Refresh();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a y-axis that is suitable for drawing this plot.
        /// </summary>
        /// <returns>A suitable y-axis.</returns>
        public Axis SuggestYAxis()
        {
            if (this.isStacked_)
            {
                double tmpMax = 0.0f;
                ArrayList adapterList = new ArrayList();

                HistogramPlot currentPlot = this;
                do
                {
                    adapterList.Add( new SequenceAdapter(
                        currentPlot.DataSource,
                        currentPlot.DataMember,
                        currentPlot.OrdinateData,
                        currentPlot.AbscissaData )
                    );
                } while ((currentPlot = currentPlot.stackedTo_) != null);

                SequenceAdapter[] adapters =
                    (SequenceAdapter[])adapterList.ToArray(typeof(SequenceAdapter));

                for (int i=0; i<adapters[0].Count; ++i)
                {
                    double tmpHeight = 0.0f;
                    for (int j=0; j<adapters.Length; ++j)
                    {
                        tmpHeight += adapters[j][i].Y;
                    }
                    tmpMax = Math.Max(tmpMax, tmpHeight);
                }

                Axis a = new LinearAxis(0.0f,tmpMax);
                // TODO make 0.08 a parameter.
                a.IncreaseRange( 0.08 );
                return a;
            }
            else
            {
                SequenceAdapter data =
                    new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData );

                return data.SuggestYAxis();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Helper method for Clone.
        /// </summary>
        protected void DoClone( LinearAxis b, LinearAxis a )
        {
            Axis.DoClone( b, a );

            a.numberSmallTicks_ = b.numberSmallTicks_;
            a.largeTickValue_ = b.largeTickValue_;
            a.largeTickStep_ = b.largeTickStep_;

            a.offset_ = b.offset_;
            a.scale_ = b.scale_;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Deep copy of LinearAxis.
 /// </summary>
 /// <returns>A copy of the LinearAxis Class</returns>
 public override object Clone()
 {
     LinearAxis a = new LinearAxis();
     // ensure that this isn't being called on a derived type. If it is, then oh no!
     if (this.GetType() != a.GetType())
     {
         throw new FlorenceException( "Clone not defined in derived type. Help!" );
     }
     this.DoClone( this, a );
     return a;
 }
Ejemplo n.º 7
0
        private void Tests_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Rectangle boundingBox;

            Florence.LinearAxis a = new LinearAxis(0, 10);
            a.Draw( e.Graphics, new Point(10,10), new Point(10, 200), out boundingBox );

            a.Reversed = true;
            a.Draw( e.Graphics, new Point(40,10), new Point(40, 200), out boundingBox );

            a.SmallTickSize = 0;
            a.Draw( e.Graphics, new Point(70,10), new Point(70, 200), out boundingBox );

            a.LargeTickStep = 2.5;
            a.Draw( e.Graphics, new Point(100,10), new Point(100,200), out boundingBox );

            a.NumberOfSmallTicks = 5;
            a.SmallTickSize = 2;
            a.Draw( e.Graphics, new Point(130,10), new Point(130,200), out boundingBox );

            a.AxisColor = Color.Cyan;
            a.Draw( e.Graphics, new Point(160,10), new Point(160,200), out boundingBox );

            a.TickTextColor= Color.Cyan;
            a.Draw( e.Graphics, new Point(190,10), new Point(190,200), out boundingBox );

            a.TickTextBrush = Brushes.Black;
            a.AxisPen = Pens.Black;
            a.Draw( e.Graphics, new Point(220,10), new Point(280,200), out boundingBox );

            a.WorldMax = 100000;
            a.WorldMin = -3;
            a.LargeTickStep = double.NaN;
            a.Draw( e.Graphics, new Point(310,10), new Point(310,200), out boundingBox );

            a.NumberFormat = "{0:0.0E+0}";
            a.Draw( e.Graphics, new Point(360,10), new Point(360,200), out boundingBox );
        }