The class implementing logarithmic axes.
Inheritance: Axis
Example #1
0
        private void DrawAxisTests(Context ctx, Rectangle bounds)
        {
            Rectangle boundingBox;
            Point tl = Point.Zero;
            Point br = Point.Zero;;

            tl.X = bounds.Left + 30;	tl.Y = bounds.Top + 20;
            br.X = bounds.Right - 30;	br.Y = bounds.Top + 20;

            LogAxis log = new LogAxis (1, 10000);

            log.Draw (ctx, tl, br, out boundingBox);

            log.Reversed = true;
            tl.Y += 50;	br.Y += 50;

            log.Draw (ctx, br, tl, out boundingBox);

            // Test for default TicksAngle on positive X-axis, ie Ticks below X-axis
            LogAxis lx = new LogAxis (100, 100000);
            lx.NumberFormat = "{0:0.0E+0}";

            tl.X = bounds.Left + 30;	tl.Y = bounds.Bottom - 60;
            br.X = bounds.Right - 30;	br.Y = bounds.Bottom - 60;

            lx.Draw (ctx, tl, br, out boundingBox);
        }
Example #2
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_;
		}
Example #3
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;
		}
Example #4
0
        public PlotLogLin()
        {
            infoText = "";
            infoText += "LogLin Example. Demonstrates - \n";
            infoText += "  * How to chart data against log axes and linear axes at the same time.";

            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, XAxisPosition.Bottom, 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();
        }
Example #5
0
        public PlotLogLog()
        {
            infoText = "";
            infoText += "LogLog Example. Demonstrates - \n";
            infoText += " * How to chart data against log axes and linear axes at the same time. \n";
            infoText += " * Plot Drag (Vertical) - try clicking and dragging in the Plot area \n";
            infoText += " * Plot Drag (Vertical) - try Ctrl + clicking and dragging in the Plot area";

            // 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, XAxisPosition.Top, 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.AddInteraction ( new PlotDrag(false,true));

            plotSurface.Refresh();
        }
Example #6
0
        public void PlotLogLog()
        {
            // 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.Refresh();
        }