Beispiel #1
0
        /// <summary>
        /// Draws NPlot.ImagePlot (heatmap).
        /// Does Clear(), axis are hidden.
        /// Can be used for icons as well.
        /// </summary>
        /// <param name="plotSurface2D">
        /// A <see cref="IPlotSurface2D"/>
        /// </param>
        /// <param name="table">
        /// A <see cref="Table3D"/>
        /// </param>
        public static void Draw(IPlotSurface2D plotSurface2D, Table3D table)
        {
            float[] valuesZ = table.GetValuesZasFloats();

            // NPlot ImagePlot, needs 2D-array of type double
            int cyi = table.CountY - 1;
            int cx  = table.CountX;

            double[,] data = new double[table.CountY, cx];
            for (int i = 0; i < valuesZ.Length; i++)
            {
                // [row, col], include y-reordering, same effect as plotSurface.YAxis1.Reversed
                // not using using YAxis1.Reversed seems to avoid a display bug (white row sometimes included)
                data[cyi - i / cx, i % cx] = valuesZ[i];
            }

            var ip = new ImagePlot(data);

            ip.Gradient = gradient;

            plotSurface2D.Clear();
            plotSurface2D.Add(ip);

            plotSurface2D.XAxis1.Hidden = true;
            plotSurface2D.YAxis1.Hidden = true;
        }
Beispiel #2
0
        public Plot2D(IPlotSurface2D plotSurface)
        {
            this.plotSurface2D = plotSurface;

            pen    = new System.Drawing.Pen(System.Drawing.Color.Red, PenWidth);
            marker = new Marker(Marker.MarkerType.FilledCircle, MarkerSize, System.Drawing.Color.Blue);
        }
Beispiel #3
0
        public Plot2D(IPlotSurface2D plotSurface)
        {
            this.plotSurface2D = plotSurface;

            pen = new System.Drawing.Pen (System.Drawing.Color.Red, PenWidth);
            marker = new Marker (Marker.MarkerType.FilledCircle, MarkerSize, System.Drawing.Color.Blue);
        }
Beispiel #4
0
	static public void PlotWavelet(IPlotSurface2D plot)
	{	
		plot.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;
		
		Grid myGrid = new Grid();
		myGrid.VerticalGridType = Grid.GridType.Fine;
		myGrid.HorizontalGridType = Grid.GridType.Coarse;
		plot.Add(myGrid);

		// And add it to the plot surface
		plot.Add( lp );
		plot.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( plot.YAxis1 );
		myAxis.NumberOfSmallTicks = 10;
		plot.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. 
		plot.XAxis1.WorldMax = 100.0f;
		
		plot.PlotBackColor = Color.Beige;
		plot.XAxis1.Reversed = true;
		plot.YAxis1.Reversed = true;
		
		// Force a re-draw of the control. 
		//plot.Refresh();
	}
Beispiel #5
0
        /// <summary>
        /// Draws NPlot.ImagePlot.
        /// Does Clear(), axis are hidden.
        /// Can be used for icons as well.
        /// </summary>
        /// <param name="plotSurface2D">
        /// A <see cref="IPlotSurface2D"/>
        /// </param>
        /// <param name="table">
        /// A <see cref="Table3D"/>
        /// </param>
        public static void Draw(IPlotSurface2D plotSurface2D, Table3D table)
        {
            float[] valuesZ = table.GetValuesZasFloats ();

            // NPlot ImagePlot, needs 2D-array of type double
            int cyi = table.CountY - 1;
            int cx = table.CountX;
            double[,] data = new double[table.CountY, cx];
            for (int i = 0; i < valuesZ.Length; i++) {
                // [row, col], include y-reordering, same effect as plotSurface.YAxis1.Reversed
                // not using using YAxis1.Reversed seems to avoid a display bug (white row sometimes included)
                data[cyi - i / cx, i % cx] = valuesZ[i];
            }

            var ip = new ImagePlot (data);
            ip.Gradient = gradient;

            plotSurface2D.Clear ();
            plotSurface2D.Add (ip);

            plotSurface2D.XAxis1.Hidden = true;
            plotSurface2D.YAxis1.Hidden = true;
        }
Beispiel #6
0
	static public void PlotTest(IPlotSurface2D plotSurface)
	{
		plotSurface.Clear();
		
		plotSurface.Title = "My Title";
		
		double[] a = {0, 2, 1, 4, double.NaN, double.NaN, 5, 8, 7, 9};
		LinePlot lp = new LinePlot();
		lp.DataSource = a;
		lp.Label = "My Label";
		
		plotSurface.Add( lp );
		
		// plotSurface.Add( lp );
		
		plotSurface.Legend = new Legend();
		plotSurface.Legend.NeverShiftAxes = true;
		plotSurface.Legend.HorizontalEdgePlacement = Legend.Placement.Inside;
		plotSurface.Legend.VerticalEdgePlacement = Legend.Placement.Inside;
		plotSurface.Legend.XOffset = -10;
		plotSurface.Legend.YOffset = 10;
		//plotSurface.AddAxesConstraint( new AxesConstraint.EqualSpacing() );
		
		((LinearAxis)plotSurface.XAxis1).Offset = 10.0;
		((LinearAxis)plotSurface.XAxis1).Scale = 27.0;
		//((LinearAxis)plotSurface.XAxis1).TicksIndependentOfPhysicalExtent = true;
		//((LinearAxis)plotSurface.YAxis1).TicksIndependentOfPhysicalExtent = true;
		
		//plotSurface.Refresh();
	}