/// <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; }
public void PlotWavelet() { string lines = "Wavelet Example. Demonstrates - * Reversing axes, setting number of tick marks on axis explicitly."; infoBox.Text = lines; this.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; this.plotSurface.Add(myGrid); // And add it to the plot surface this.plotSurface.Add( lp ); this.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( this.plotSurface.YAxis1 ); myAxis.NumberOfSmallTicks = 2; this.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. this.plotSurface.XAxis1.WorldMax = 100.0f; this.plotSurface.PlotBackColor = Color.OldLace; this.plotSurface.XAxis1.Reversed = true; this.plotSurface.YAxis1.Reversed = true; // Force a re-draw of the control. this.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(); }
private void chart3_InteractionOccured(object sender) { LinearAxis axis1 = new LinearAxis(chart3.XAxis1); axis1.Label = ""; axis1.HideTickText = true; this.chart2.XAxis1 = axis1; this.chart2.Refresh(); LinearAxis axis2 = new LinearAxis(chart3.XAxis1); axis2.Label = ""; axis2.HideTickText = true; this.chart1.XAxis1 = axis2; this.chart1.Refresh(); SetStatusNow(); }
private void chart2_InteractionOccured(object sender) { LinearAxis axis1 = new LinearAxis(chart2.XAxis1); axis1.Label = ""; axis1.HideTickText = true; this.chart1.XAxis1 = axis1; this.chart1.Refresh(); LabelAxis axis2 = new LabelAxis(chart2.XAxis1); int tick = 1; if (chart2.XAxis1.WorldMax - chart2.XAxis1.WorldMin > 30) tick = 2; for (int i = (int)chart2.XAxis1.WorldMin; i <= chart2.XAxis1.WorldMax; i+=tick) { int j = i % 24; if (j < 0) j += 24; axis2.AddLabel(Convert.ToString(j), i); } axis2.Label = "Time:Hour"; axis2.HideTickText = false; chart3.XAxis1 = axis2; this.chart3.Refresh(); SetStatusNow(); }
/// <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(); } }
/// <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_; }
/// <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 NPlotException( "Clone not defined in derived type. Help!" ); } this.DoClone( this, a ); return a; }