Пример #1
0
 /// <summary>
 /// Helper method for Clone (actual implementation)
 /// </summary>
 /// <param name="a">The original object to clone.</param>
 /// <param name="b">The cloned object.</param>
 protected void DoClone(LogAxis b, LogAxis a)
 {
     Axis.DoClone(b, a);
     // add specific elemtents of the class for the deep copy of the object
     a.numberSmallTicks_ = b.numberSmallTicks_;
     a.largeTickValue_   = b.largeTickValue_;
     a.largeTickStep_    = b.largeTickStep_;
 }
Пример #2
0
        /// <summary>
        /// Deep Copy of the LogAxis.
        /// </summary>
        /// <returns>A Copy of the LogAxis Class.</returns>
        public override object Clone()
        {
            LogAxis a = new LogAxis();

            if (this.GetType() != a.GetType())
            {
                throw new NPlotException("Clone not defined in derived type. Help!");
            }
            this.DoClone(this, a);
            return(a);
        }
        public void PlotLogLog()
        {
            string lines ="LogLog Example. Demonstrates -  * How to chart data against log axes and linear axes at the same time.";
            infoBox.Text = lines;

            // log log plot
            plotSurface.Clear();

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

            int npt = 101;
            float [] x = new float[npt];
            float [] y = new float[npt];

            float step=0.1f;

            // plot a power law on the log-log scale
            for (int i=0; i<npt; ++i)
            {
                x[i] = (i+1)*step;
                y[i] = x[i]*x[i];
            }
            float xmin = x[0];
            float xmax = x[npt-1];
            float ymin = y[0];
            float ymax = y[npt-1];

            LinePlot lp = new LinePlot();
            lp.OrdinateData = y;
            lp.AbscissaData = x;
            lp.Pen = new Pen( Color.Red );
            plotSurface.Add( lp );
            // axes
            // x axis
            LogAxis logax = new LogAxis( plotSurface.XAxis1 );
            logax.WorldMin = xmin;
            logax.WorldMax = xmax;
            logax.AxisColor = Color.Red;
            logax.LabelColor = Color.Red;
            logax.TickTextColor = Color.Red;
            logax.LargeTickStep = 1.0f;
            logax.Label = "x";
            plotSurface.XAxis1 = logax;
            // y axis
            LogAxis logay = new LogAxis( plotSurface.YAxis1 );
            logay.WorldMin = ymin;
            logay.WorldMax = ymax;
            logay.AxisColor = Color.Red;
            logay.LabelColor = Color.Red;
            logay.TickTextColor = Color.Red;
            logay.LargeTickStep = 1.0f;
            logay.Label = "x^2";
            plotSurface.YAxis1 = logay;

            LinePlot lp1 = new LinePlot();
            lp1.OrdinateData = y;
            lp1.AbscissaData = x;
            lp1.Pen = new Pen( Color.Blue );
            plotSurface.Add( lp1, PlotSurface2D.XAxisPosition.Top, PlotSurface2D.YAxisPosition.Right );
            // axes
            // x axis (lin)
            LinearAxis linx = (LinearAxis) plotSurface.XAxis2;
            linx.WorldMin = xmin;
            linx.WorldMax = xmax;
            linx.AxisColor = Color.Blue;
            linx.LabelColor = Color.Blue;
            linx.TickTextColor = Color.Blue;
            linx.Label = "x";
            plotSurface.XAxis2 = linx;
            // y axis (lin)
            LinearAxis liny = (LinearAxis) plotSurface.YAxis2;
            liny.WorldMin = ymin;
            liny.WorldMax = ymax;
            liny.AxisColor = Color.Blue;
            liny.LabelColor = Color.Blue;
            liny.TickTextColor = Color.Blue;
            liny.Label = "x^2";
            plotSurface.YAxis2 = liny;

            plotSurface.Title = "x^2 plotted with log(red)/linear(blue) axes";
            plotSurface.XAxis1.LabelOffset = 0;
            plotSurface.YAxis1.LabelOffset = 0;
            plotSurface.Refresh();
        }
        public void PlotLogAxis()
        {
            string lines = "Log Example. Demonstrates -  * How to chart data against log axes and linear axes at the same time.";
            infoBox.Text = lines;

            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 = 0;
            plotSurface.YAxis1.LabelOffset = 0;
            plotSurface.Refresh();
        }
Пример #5
0
 /// <summary>
 /// Helper method for Clone (actual implementation)
 /// </summary>
 /// <param name="a">The original object to clone.</param>
 /// <param name="b">The cloned object.</param>
 protected void DoClone(LogAxis b, LogAxis a)
 {
     Axis.DoClone(b,a);
     // add specific elemtents of the class for the deep copy of the object
     a.numberSmallTicks_ = b.numberSmallTicks_;
     a.largeTickValue_ = b.largeTickValue_;
     a.largeTickStep_ = b.largeTickStep_;
 }
Пример #6
0
 /// <summary>
 /// Deep Copy of the LogAxis.
 /// </summary>
 /// <returns>A Copy of the LogAxis Class.</returns>
 public override object Clone()
 {
     LogAxis a = new LogAxis();
     if (this.GetType() != a.GetType())
     {
         throw new NPlotException("Clone not defined in derived type. Help!");
     }
     this.DoClone( this, a );
     return a;
 }