Exemple #1
0
        void DrawNMIteration(NMIteration it)
        {
            ReadGraphParams();
            if (it.arrXRes.Length != 2)
            {
                throw new Exception();
            }
            psItGraph.Remove(lpItLast, false);
            psItGraph.Remove(ppItLast, false);
            double[] arrX = new double[] {
                it.matrX[0][0], it.matrX[1][0], it.matrX[2][0], it.matrX[0][0]
            };
            double[] arrY = new double[] {
                it.matrX[0][1], it.matrX[1][1], it.matrX[2][1], it.matrX[0][1]
            };
            lpItLast = new LinePlot();
            lpItLast.OrdinateData = arrY;
            lpItLast.AbscissaData = arrX;
            lpItLast.Pen          = new Pen(Color.Green, 2f);
            psItGraph.Add(lpItLast);

            ppItLast = new PointPlot(new Marker(Marker.MarkerType.Circle, 4));
            ppItLast.OrdinateData = new double[] { it.arrXRes[1] };
            ppItLast.AbscissaData = new double[] { it.arrXRes[0] };
            psItGraph.Add(ppItLast);

            psItGraph.XAxis1.WorldMin = xMin;
            psItGraph.XAxis1.WorldMax = xMax;
            psItGraph.YAxis1.WorldMin = yMin;
            psItGraph.YAxis1.WorldMax = yMax;
            psItGraph.XAxis1.Label    = (string)dgvX.Rows[0].Cells["Имя"].Value;
            psItGraph.YAxis1.Label    = (string)dgvX.Rows[1].Cells["Имя"].Value;
            psItGraph.Refresh();
        }
Exemple #2
0
        void DrawNMTrajectory()
        {
            ReadGraphParams();
            if (listNM[0].arrXRes.Length != 2)
            {
                throw new Exception();
            }
            psGraph.Remove(lpTrLast, false);
            psGraph.Remove(ppTrLast, false);
            double[] arrX = new double[listNM.Count];
            double[] arrY = new double[listNM.Count];
            for (int i = 0; i < listNM.Count; i++)
            {
                arrX[i] = listNM[i].arrXRes[0];
                arrY[i] = listNM[i].arrXRes[1];
            }
            lpTrLast = new LinePlot();
            lpTrLast.OrdinateData = arrY;
            lpTrLast.AbscissaData = arrX;
            lpTrLast.Pen          = new Pen(Color.Blue);
            psGraph.Add(lpTrLast);
            ppTrLast = new PointPlot(new Marker(Marker.MarkerType.Circle, 4));
            ppTrLast.OrdinateData = arrY;
            ppTrLast.AbscissaData = arrX;
            psGraph.Add(ppTrLast);

            psGraph.XAxis1.WorldMin = xMin;
            psGraph.XAxis1.WorldMax = xMax;
            psGraph.YAxis1.WorldMin = yMin;
            psGraph.YAxis1.WorldMax = yMax;
            psGraph.XAxis1.Label    = (string)dgvX.Rows[0].Cells["Имя"].Value;
            psGraph.YAxis1.Label    = (string)dgvX.Rows[1].Cells["Имя"].Value;
            psGraph.Refresh();
        }
Exemple #3
0
        public PlotSinc()
        {
            infoText  = "";
            infoText += "Sinc Function Example. Demonstrates - \n";
            infoText += " * Charting line and point plot at the same time. \n";
            infoText += " * Adding a legend.";

            plotSurface.Clear();             // clear everything. reset fonts. remove plot components etc.

            System.Random r    = new Random();
            double[]      a    = new double[100];
            double[]      b    = new double[100];
            double        mult = 0.00001f;

            for (int i = 0; i < 100; ++i)
            {
                a[i] = ((double)r.Next(1000) / 5000.0f - 0.1f) * mult;
                if (i == 50)
                {
                    b[i] = 1.0f * mult;
                }
                else
                {
                    b[i]  = (double)Math.Sin((((double)i - 50.0f) / 4.0f)) / (((double)i - 50.0f) / 4.0f);
                    b[i] *= mult;
                }
                a[i] += b[i];
            }

            Marker    m  = new Marker(Marker.MarkerType.Cross1, 6, new Pen(Color.Blue, 2.0F));
            PointPlot pp = new PointPlot(m);

            pp.OrdinateData = a;
            pp.AbscissaData = new StartStep(-500.0, 10.0);
            pp.Label        = "Random";
            plotSurface.Add(pp);

            LinePlot lp = new LinePlot();

            lp.OrdinateData = b;
            lp.AbscissaData = new StartStep(-500.0, 10.0);
            lp.Pen          = new Pen(Color.Red, 2.0f);
            plotSurface.Add(lp);

            plotSurface.Title        = "Sinc Function";
            plotSurface.YAxis1.Label = "Magnitude";
            plotSurface.XAxis1.Label = "Position";

            Legend legend = new Legend();

            legend.AttachTo(XAxisPosition.Top, YAxisPosition.Left);
            legend.VerticalEdgePlacement   = Legend.Placement.Inside;
            legend.HorizontalEdgePlacement = Legend.Placement.Inside;
            legend.YOffset = 8;

            plotSurface.Legend       = legend;
            plotSurface.LegendZOrder = 1;             // default zorder for adding idrawables is 0, so this puts legend on top.

            plotSurface.Refresh();
        }
Exemple #4
0
        private void RefreshRetrievePlot()
        {
            _retrieveSpeedPlot.Clear();
            PointPlot plot = new PointPlot();

            List <DateTime> timePoints;
            List <double>   retrieveMbPerSecond;

            ComputePlotAverage(out timePoints, out retrieveMbPerSecond);

            plot.AbscissaData = timePoints;
            plot.DataSource   = retrieveMbPerSecond;

            Grid grid = new Grid();

            grid.HorizontalGridType = Grid.GridType.Coarse;
            grid.VerticalGridType   = Grid.GridType.Coarse;

            _retrieveSpeedPlot.Add(grid);
            _retrieveSpeedPlot.Add(plot);

            _retrieveSpeedPlot.ShowCoordinates            = true;
            _retrieveSpeedPlot.YAxis1.Label               = "Mb/sec";
            _retrieveSpeedPlot.YAxis1.LabelOffsetAbsolute = true;
            _retrieveSpeedPlot.YAxis1.LabelOffset         = 40;
            _retrieveSpeedPlot.Padding = 5;

            //Align percent plot axes.
            DateTimeAxis ax = new DateTimeAxis(_retrieveSpeedPlot.XAxis1);

            ax.HideTickText           = false;
            _retrieveSpeedPlot.XAxis1 = ax;

            _retrieveSpeedPlot.Refresh();
        }
Exemple #5
0
        private void DrawObsSpecGraph()
        {
            plotObsSpectrum.Clear();

            // add masks;
            int num = lbRanges.SelectedIndex;

            for (int i = 0; i < cutMask.Size(); i++)
            {
                NPlot.VerticalLine vl1 = new VerticalLine(this.cutMask.GetLeftBound(i));
                NPlot.VerticalLine vl2 = new VerticalLine(this.cutMask.GetRightBound(i));
                NPlot.FilledRegion fr  = new FilledRegion(vl1, vl2);
                fr.Brush = Brushes.Coral;
                if (num == i)
                {
                    fr.Brush = Brushes.Gray;
                }
                plotObsSpectrum.Add(fr);
            }

            // add observed spectrum;
            if (this.obsSpectrum != null)
            {
                LinePlot lp = new LinePlot();
                lp.AbscissaData = this.obsSpectrum.LambdaSet;
                lp.OrdinateData = this.obsSpectrum.FluxSet;
                lp.Pen          = new Pen(Color.Black, 1.0f);
                plotObsSpectrum.Add(lp);
            }

            // add continum;
            if (this.contSpectrum != null)
            {
                LinePlot lpCont = new LinePlot(this.contSpectrum.FluxSet, this.contSpectrum.LambdaSet);
                lpCont.Pen = new Pen(Color.Red, 2.0f);
                plotObsSpectrum.Add(lpCont);
            }

            // add rejected points;
            if (this.rejectSpectrum != null && this.rejectSpectrum.Size > 0)
            {
                PointPlot ppRej = new PointPlot();
                ppRej.AbscissaData = this.rejectSpectrum.LambdaSet;
                ppRej.OrdinateData = this.rejectSpectrum.FluxSet;
                ppRej.Marker       = new Marker(Marker.MarkerType.Diamond, 4, Color.Red);
                plotObsSpectrum.Add(ppRej);
            }

            plotObsSpectrum.Title        = "Observed spectrum";
            plotObsSpectrum.YAxis1.Label = "Flux";
            plotObsSpectrum.XAxis1.Label = "Lambda";

            plotObsSpectrum.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            plotObsSpectrum.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());
            plotObsSpectrum.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(true));

            plotObsSpectrum.Refresh();
        }
Exemple #6
0
        /// <summary>
        /// Might need Refresh () afterwards!
        /// </summary>
        /// <param name="table2D">
        /// A <see cref="Table2D"/>
        /// </param>
        public void Draw(Tables.Denso.Table2D table2D)
        {
            float[] valuesY = table2D.GetValuesYasFloats();

            // clear everything. reset fonts. remove plot components etc.
            // including Florence interactions
            this.plotSurface2D.Clear();

            // Florence interactions, N/A in original NPlot library
            // guideline disadvantage: not optimized - does not use bitmap buffer, refreshes every time a line has to move
            plotSurface2D.AddInteraction(new VerticalGuideline(Color.Gray));
            plotSurface2D.AddInteraction(new HorizontalGuideline(Color.Gray));

            //plotSurface2D.AddInteraction (new PlotSelection (Color.Green));
            plotSurface2D.AddInteraction(new PlotDrag(true, true));

            plotSurface2D.AddInteraction(new AxisDrag());
            // PlotZoom: mouse wheel zoom
            plotSurface2D.AddInteraction(new PlotZoom());
            plotSurface2D.AddInteraction(new KeyActions());

            plotSurface2D.SurfacePadding = 0;
            plotSurface2D.SmoothingMode  = SmoothingMode;

            // y-values, x-values (!)
            LinePlot lp = new LinePlot(valuesY, table2D.ValuesX);

            lp.Pen = pen;

            PointPlot pp = new PointPlot(marker);

            pp.AbscissaData = table2D.ValuesX;
            pp.OrdinateData = valuesY;

            Grid myGrid = new Grid();

            myGrid.VerticalGridType   = Grid.GridType.Coarse;
            myGrid.HorizontalGridType = Grid.GridType.Coarse;

            plotSurface2D.Add(myGrid);
            plotSurface2D.Add(pp);
            plotSurface2D.Add(lp);

            plotSurface2D.TitleFont = titleFont;
            plotSurface2D.Title     = table2D.Title;

            plotSurface2D.XAxis1.LabelFont = labelFont;
            plotSurface2D.XAxis1.Label     = AxisText(table2D.NameX, table2D.UnitX);
            // could use ex: plotSurface2D.YAxis1.NumberFormat = "0.000";
            plotSurface2D.XAxis1.TickTextFont = tickTextFont;

            plotSurface2D.YAxis1.LabelFont    = labelFont;
            plotSurface2D.YAxis1.Label        = AxisText(table2D.Title, table2D.UnitY);
            plotSurface2D.YAxis1.TickTextFont = tickTextFont;

            // Florence surface has Refresh () method vs. NPlot: Refresh () not part of surface interface
            plotSurface2D.Refresh();
        }
Exemple #7
0
        private PointPlot genPlot(double[] xData, double[] yData, Color color)
        {
            PointPlot answer = new PointPlot();

            answer.Marker       = genMarker(color);
            answer.AbscissaData = xData;
            answer.OrdinateData = yData;
            return(answer);
        }
Exemple #8
0
        private void DrawPointPlot(DataTable dt)
        {
            #region 1.初始化 volumePS
            this.volumePS = new NPlot.Windows.PlotSurface2D();

            //
            // volumePS
            //
            this.volumePS.AutoScaleAutoGeneratedAxes = false;
            this.volumePS.AutoScaleTitle             = false;
            this.volumePS.BackColor       = System.Drawing.SystemColors.ControlLightLight;
            this.volumePS.DateTimeToolTip = false;
            this.volumePS.Legend          = null;
            this.volumePS.LegendZOrder    = -1;
            //this.volumePS.Location = new System.Drawing.Point(70, 636);
            this.volumePS.Dock            = DockStyle.Fill;
            this.volumePS.Name            = "volumePS";
            this.volumePS.RightMenu       = null;
            this.volumePS.ShowCoordinates = false;
            this.volumePS.Size            = new System.Drawing.Size(1053, 139);
            this.volumePS.SmoothingMode   = System.Drawing.Drawing2D.SmoothingMode.None;
            this.volumePS.TabIndex        = 3;
            this.volumePS.Title           = "";
            this.volumePS.TitleFont       = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
            this.volumePS.XAxis1          = null;
            this.volumePS.XAxis2          = null;
            this.volumePS.YAxis1          = null;
            this.volumePS.YAxis2          = null;
            #endregion
            /*--============================================volumePS-PointPlot========================================================--*/
            #region 3.1 创建PointPlot【pp】.
            PointPlot pp = new PointPlot();
            pp.Marker          = new Marker(Marker.MarkerType.Square, 0);
            pp.Marker.Pen      = new Pen(Color.Red, 5.0f);
            pp.Marker.DropLine = true;
            pp.DataSource      = dt;
            pp.AbscissaData    = "Date";
            pp.OrdinateData    = "Volume";
            #endregion

            #region 3.2 添加pp到volumePS
            volumePS.Clear();

            volumePS.Add(pp);
            volumePS.YAxis1.Label = "Volume";
            volumePS.YAxis1.LabelOffsetAbsolute = true;
            volumePS.YAxis1.LabelOffset         = 40;
            volumePS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));
            volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
            volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            volumePS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(volumePS_InteractionOccured);
            volumePS.PreRefresh         += new NPlot.Windows.PlotSurface2D.PreRefreshHandler(volumePS_PreRefresh);
            #endregion
        }
Exemple #9
0
        public void ShowSpectrum(string Filename)
        {
            try
            {
                while (!_spectrumProcess.HasExited)
                {
                    Thread.Sleep(50);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Failed to get spectrum results");
                return;
            }
            LinePlot  lp = new LinePlot();
            PointPlot pp = new PointPlot();

            NPlot.Bitmap.PlotSurface2D npSurface = new NPlot.Bitmap.PlotSurface2D(1000, 1000);

            try
            {
                Tuple <float[], float[]> Data = ReadFile(Filename);
                if (Data == null)
                {
                    return;
                }
                lp.AbscissaData = Data.Item1;
                lp.DataSource   = Data.Item2;
                lp.Color        = System.Drawing.Color.Green;
                npSurface.Add(lp);
                npSurface.XAxis1.Label = "Frequncy [Hz]";
                npSurface.YAxis1.Label = "Power [db]";
                npSurface.Title        = "Central Frequncy = " + (_central_frequncy / 1e6).ToString() + " MHz - Bandwidth = " + (_rate / 1e6).ToString() + " MHz";
                npSurface.BackColor    = System.Drawing.Color.White;

                npSurface.Refresh();

                MemoryStream ms = new MemoryStream();
                npSurface.Bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                ms.Position = 0;
                Gtk.Application.Invoke(delegate
                {
                    Pixbuf p = new Gdk.Pixbuf(ms);

                    image.Pixbuf = p;
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemple #10
0
        private void btnOrdIdent_RefreshPlot_Click(object sender, EventArgs e)
        {
            plotOrdIdent.Clear();

            if (this.slice == null || this.orders_pos == null || this.orders_ident == null)
            {
                return;
            }

            LinePlot lp = new LinePlot(this.slice.Data[1], this.slice.Data[0]);

            lp.Pen = new Pen(Color.Black, 2.0f);
            plotOrdIdent.Add(lp);


            if (cbOrdIdent_OrdPos.Checked)
            {
                for (int i = 0; i < orders_pos.Data[0].Length; i++)
                {
                    VerticalLine vl = new VerticalLine(orders_pos.Data[0][i]);
                    vl.Pen = new Pen(Color.Red);
                    plotOrdIdent.Add(vl);
                }
            }

            if (cbOrdIdent_IdentOrders.Checked)
            {
                for (int i = 0; i < this.orders_ident.Data[0].Length; i++)
                {
                    PointPlot pp = new PointPlot(new Marker(Marker.MarkerType.FilledCircle, 6, Color.Blue));
                    double[]  xx = new double[1];
                    double[]  yy = new double[1];
                    xx[0]           = orders_ident.Data[0][i];
                    yy[0]           = this.slice.Data[1][(int)orders_ident.Data[0][i]] + 100;
                    pp.OrdinateData = yy;
                    pp.AbscissaData = xx;
                    plotOrdIdent.Add(pp);
                    //NPlot.FilledRegion fr = new FilledRegion(
                    //    new VerticalLine(this.orders_ident.Data[0][i] - 2), new VerticalLine(this.orders_ident.Data[0][i] + 2));
                    //fr.Brush = Brushes.Orange;
                    //plotOrdIdent.Add(fr);
                }
            }

            plotOrdIdent.XAxis1.Label = "Pixel Number";
            plotOrdIdent.YAxis1.Label = "Flux";
            plotOrdIdent.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            plotOrdIdent.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());
            plotOrdIdent.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(true));
            plotOrdIdent.Refresh();
        }
Exemple #11
0
        private void drawPoint(double xVal, double temp)
        {
            PointPlot pp = new PointPlot();

            double [] x = new double[1];
            x[0] = xVal;
            double [] y = new double[1];
            y[0]            = temp;
            pp.AbscissaData = x;
            pp.OrdinateData = y;
            plotSurface.Add(pp);

            plotSurface.Refresh();
        }
Exemple #12
0
        public PlotMarkerSample() : base()
        {
            infoText  = "";
            infoText += "Markers Example. Demonstrates - \n";
            infoText += " * PointPlot and the available marker types \n";
            infoText += " * Legends, and how to place them.";

            plotCanvas.Clear();

            double[] y = new double[1] {
                1.0
            };
            foreach (object i in Enum.GetValues(typeof(Marker.MarkerType)))
            {
                Marker m = new Marker((Marker.MarkerType)Enum.Parse(typeof(Marker.MarkerType), i.ToString()), 8);
                m.FillColor = Colors.Red;
                double[] x = new double[1];
                x[0] = (double)m.Type;
                PointPlot pp = new PointPlot();
                pp.OrdinateData = y;
                pp.AbscissaData = x;
                pp.Marker       = m;
                pp.Label        = m.Type.ToString();
                plotCanvas.Add(pp);
            }
            plotCanvas.Title            = "Markers";
            plotCanvas.YAxis1.Label     = "Index";
            plotCanvas.XAxis1.Label     = "Marker";
            plotCanvas.YAxis1.WorldMin  = 0.0;
            plotCanvas.YAxis1.WorldMax  = 2.0;
            plotCanvas.XAxis1.WorldMin -= 1.0;
            plotCanvas.XAxis1.WorldMax += 1.0;

            Legend legend = new Legend();

            legend.AttachTo(XAxisPosition.Top, YAxisPosition.Right);
            legend.VerticalEdgePlacement   = Legend.Placement.Outside;
            legend.HorizontalEdgePlacement = Legend.Placement.Inside;
            legend.XOffset    = 5;          // note that these numbers can be negative.
            legend.YOffset    = 0;
            plotCanvas.Legend = legend;

            PackStart(plotCanvas.Canvas, true);
            Label la = new Label(infoText);

            PackStart(la);
        }
Exemple #13
0
        private void plot(MaterialPropertyCalc calc)
        {
            // All the colors for this graph are set here
            Color allConductivityColor      = Color.Red;
            Color officialConductivityColor = Color.Black;
            Color integratedColor           = Color.Blue;

            // General set-up - label, X axis, ...
            plotSurface.Clear();
            plotSurface.Title           = calc.Name;
            plotSurface.XAxis1          = new LinearAxis();
            plotSurface.XAxis1.Label    = "Temp(Deg K)";
            plotSurface.XAxis1.WorldMin = 0.0;
            plotSurface.XAxis1.WorldMax = 350.0;

            // Plot all the thermal conductivity data - even that which is extrapolated outside the
            // "officially" valid range
            PointPlot allConductivityPlot = genPlot(calc.Temperature, calc.ThermalConductivity, allConductivityColor);

            plotSurface.Add(allConductivityPlot);

            // Plot only the "officially" valid thermal conductivity data.
            PointPlot officialConductivityPlot = genPlot(calc.OfficialTemperature, calc.OfficialThermalConductivity, officialConductivityColor);

            plotSurface.Add(officialConductivityPlot);

            // Add the axis for thermal conductivity (both official and extrapolated)
            plotSurface.YAxis1.Label    = "Thermal Conductivity (W/mK)";
            plotSurface.YAxis1.WorldMin = 0.0;

            // Plot the integrated thermal conductivity data
            PointPlot integratedConductivityPlot = genPlot(calc.Temperature, calc.IntegratedThermalConductivity, integratedColor);

            plotSurface.Add(integratedConductivityPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Right);

            // Add an appropriately scaled axis on the right side of the graph for the integrated conductivity data
            LinearAxis integratedConductivityAxis = new LinearAxis();

            integratedConductivityAxis.WorldMin   = 0.0;
            integratedConductivityAxis.WorldMax   = calc.IntegratedThermalConductivity[0];
            integratedConductivityAxis.LabelColor = integratedColor;
            integratedConductivityAxis.Label      = "Integrated Thermal Conductivity (W/m)";
            plotSurface.YAxis2 = integratedConductivityAxis;

            plotSurface.Refresh();
        }
Exemple #14
0
        /// <summary>
        /// Might need Refresh () afterwards!
        /// </summary>
        /// <param name="table2D">
        /// A <see cref="Table2D"/>
        /// </param>
        public void Draw(Table2D table2D)
        {
            float[] valuesY = table2D.GetValuesYasFloats();

            // clear everything. reset fonts. remove plot components etc.
            this.plotSurface2D.Clear();
            plotSurface2D.Padding       = 0;
            plotSurface2D.SmoothingMode = SmoothingMode;

            // y-values, x-values (!)
            LinePlot lp = new LinePlot(valuesY, table2D.ValuesX);

            lp.Pen = pen;

            PointPlot pp = new PointPlot(marker);

            pp.AbscissaData = table2D.ValuesX;
            pp.OrdinateData = valuesY;

            Grid myGrid = new Grid();

            myGrid.VerticalGridType   = Grid.GridType.Coarse;
            myGrid.HorizontalGridType = Grid.GridType.Coarse;

            plotSurface2D.Add(myGrid);
            plotSurface2D.Add(lp);
            plotSurface2D.Add(pp);

            plotSurface2D.TitleFont = titleFont;
            plotSurface2D.Title     = table2D.Title;

            plotSurface2D.XAxis1.LabelFont = labelFont;
            plotSurface2D.XAxis1.Label     = AxisText(table2D.NameX, table2D.UnitX);
            // could use ex: plotSurface2D.YAxis1.NumberFormat = "0.000";
            plotSurface2D.XAxis1.TickTextFont = tickTextFont;

            plotSurface2D.YAxis1.LabelFont    = labelFont;
            plotSurface2D.YAxis1.Label        = AxisText(table2D.Title, table2D.UnitY);
            plotSurface2D.YAxis1.TickTextFont = tickTextFont;

            // Refresh () not part of interface!
        }
Exemple #15
0
        private void btnISM_ShowStokesCurve_Click(object sender, EventArgs e)
        {
            int curveNumber = lbISM_StokesCurves.SelectedIndex;

            if (curveNumber == -1)
            {
                return;
            }

            PointPlot pp = new PointPlot(new Marker(Marker.MarkerType.FilledCircle, 3, Color.Black));

            if (this.stokesCurvesBox.StokesCurves[curveNumber].type == "I")
            {
                pp.AbscissaData = this.stokesCurvesBox.StokesCurves[curveNumber].phases;
                pp.OrdinateData = this.stokesCurvesBox.StokesCurves[curveNumber].value;
                plotISM_StokesI.Add(pp);
                plotISM_StokesI.Refresh();
            }
            if (this.stokesCurvesBox.StokesCurves[curveNumber].type == "V")
            {
                pp.AbscissaData = this.stokesCurvesBox.StokesCurves[curveNumber].phases;
                pp.OrdinateData = this.stokesCurvesBox.StokesCurves[curveNumber].value;
                plotISM_StokesV.Add(pp);
                plotISM_StokesV.Refresh();
            }
            if (this.stokesCurvesBox.StokesCurves[curveNumber].type == "Q")
            {
                pp.AbscissaData = this.stokesCurvesBox.StokesCurves[curveNumber].phases;
                pp.OrdinateData = this.stokesCurvesBox.StokesCurves[curveNumber].value;
                plotISM_StokesQ.Add(pp);
                plotISM_StokesQ.Refresh();
            }
            if (this.stokesCurvesBox.StokesCurves[curveNumber].type == "U")
            {
                pp.AbscissaData = this.stokesCurvesBox.StokesCurves[curveNumber].phases;
                pp.OrdinateData = this.stokesCurvesBox.StokesCurves[curveNumber].value;
                plotISM_StokesU.Add(pp);
                plotISM_StokesU.Refresh();
            }
        }
Exemple #16
0
        void DrawHJIteration(HJIteration it)
        {
            ReadGraphParams();
            if (it.arrX.Length != 2)
            {
                throw new Exception();
            }
            psItGraph.Remove(lpItLast, false);
            psItGraph.Remove(ppItLast, false);
            ppItLast = new PointPlot(new Marker(Marker.MarkerType.Circle, 4));
            ppItLast.OrdinateData = new double[] { it.arrX[1] };
            ppItLast.AbscissaData = new double[] { it.arrX[0] };
            psItGraph.Add(ppItLast);

            psItGraph.XAxis1.WorldMin = xMin;
            psItGraph.XAxis1.WorldMax = xMax;
            psItGraph.YAxis1.WorldMin = yMin;
            psItGraph.YAxis1.WorldMax = yMax;
            psItGraph.XAxis1.Label    = (string)dgvX.Rows[0].Cells["Имя"].Value;
            psItGraph.YAxis1.Label    = (string)dgvX.Rows[1].Cells["Имя"].Value;
            psItGraph.Refresh();
        }
Exemple #17
0
 void lbTran_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         int        index = lbTran.SelectedIndex;
         TranSample ts    = arrTranSmp[index];
         Regression reg   = arrReg[index];
         ps.Clear();
         LinePlot lp = new LinePlot();
         lp.AbscissaData = ts.CloneArray();
         lp.OrdinateData = reg.CloneArray();
         ps.Add(lp);
         PointPlot pp = new PointPlot();
         pp.AbscissaData = ts.CloneArray();
         pp.OrdinateData = smpY.CloneArray();
         ps.Add(pp);
         ps.XAxis1.Label = string.Format("{0} [{1}]", smpX.GetName(), arrTranName[index]);
         ps.YAxis1.Label = smpY.GetName();
         ps.Refresh();
     }
     catch { }
 }
Exemple #18
0
        private void plotWL_DoubleClick(object sender, EventArgs e)
        {
            MouseEventArgs eA    = (MouseEventArgs)e;
            Point          here  = new Point(eA.X, eA.Y);
            double         x     = this.plotWL.PhysicalXAxis1Cache.PhysicalToWorld(here, true);
            double         y     = this.plotWL.PhysicalYAxis1Cache.PhysicalToWorld(here, true);
            int            index = lbOrders.SelectedIndex;

            if (index == -1)
            {
                return;
            }

            if (rbDispCurve.Checked)
            {
                int       i  = thar_repers.FindLine(index, x, y);
                PointPlot pp = new PointPlot(new Marker(Marker.MarkerType.Cross2));
                pp.AbscissaData = new double[1] {
                    thar_repers.pixels_ord[index][i]
                };
                pp.OrdinateData = new double[1] {
                    thar_repers.lambda_ord[index][i]
                };
                plotWL.Add(pp);
                plotWL.Refresh();
                MessageBox.Show(string.Format("Pix = {0:0000.00}; Lambda = {1:0000.0000}",
                                              thar_repers.pixels_ord[index][i], thar_repers.lambda_ord[index][i]));
            }
            if (rbRepers.Checked)
            {
                int          i  = thar_repers.FindLine(index, x);
                VerticalLine vl = new VerticalLine(thar_repers.pixels_ord[index][i], Color.Blue);
                plotWL.Add(vl);
                plotWL.Refresh();
                MessageBox.Show(string.Format("Pix = {0:0000.00}; Lambda = {1:0000.0000}",
                                              thar_repers.pixels_ord[index][i], thar_repers.lambda_ord[index][i]));
            }
        }
Exemple #19
0
        public void CreatePlot(InteractivePlotSurface2D plotSurface)
        {
            plotSurface.Clear();

            double[] y = new double[1] {
                1.0f
            };
            foreach (object i in Enum.GetValues(typeof(Marker.MarkerType)))
            {
                Marker   m = new Marker((Marker.MarkerType)Enum.Parse(typeof(Marker.MarkerType), i.ToString()), 8);
                double[] x = new double[1];
                x[0] = (double)m.Type;
                PointPlot pp = new PointPlot();
                pp.OrdinateData = y;
                pp.AbscissaData = x;
                pp.Marker       = m;
                pp.Label        = m.Type.ToString();
                plotSurface.Add(pp);
            }
            plotSurface.Title            = "Markers";
            plotSurface.YAxis1.Label     = "Index";
            plotSurface.XAxis1.Label     = "Marker";
            plotSurface.YAxis1.WorldMin  = 0.0f;
            plotSurface.YAxis1.WorldMax  = 2.0f;
            plotSurface.XAxis1.WorldMin -= 1.0f;
            plotSurface.XAxis1.WorldMax += 1.0f;

            Legend legend = new Legend();

            legend.AttachTo(PlotSurface2D.XAxisPosition.Top, PlotSurface2D.YAxisPosition.Right);
            legend.VerticalEdgePlacement   = Legend.Placement.Outside;
            legend.HorizontalEdgePlacement = Legend.Placement.Inside;
            legend.XOffset     = 5; // note that these numbers can be negative.
            legend.YOffset     = 0;
            plotSurface.Legend = legend;

            plotSurface.Refresh();
        }
Exemple #20
0
        private void button2_Click(object sender, EventArgs e)
        {
            myPlot.Clear();           //清空
            Grid mygrid = new Grid(); //加入网格

            myPlot.Add(mygrid);

            Marker m = new Marker(Marker.MarkerType.FilledCircle, 6, new Pen(Color.Blue, 2.0F));//点状图的类型,实心圆点
            //Marker m = new Marker(Marker.MarkerType.Cross1, 6, new Pen(Color.Blue, 2.0F));//点状图的类型,叉形
            PointPlot pp = new PointPlot(m);

            int[] a = new int[] { 0, 1 };
            pp.OrdinateData = a;
            StartStep b = new StartStep(-500.0, 10.0);//根据第一个数,可以得到相差10的两个数

            pp.AbscissaData = b;
            pp.Label        = "Random";
            myPlot.Add(pp);

            myPlot.XAxis1.IncreaseRange(0.1);
            myPlot.YAxis1.IncreaseRange(0.1); //缩小到合适大小
            myPlot.Refresh();
        }
Exemple #21
0
        private void initPlot(double maxX, string xLabel)
        {
            plotSurface.Clear();

            PointPlot pp = new PointPlot();
            Marker    m  = new Marker();

            double[] x = { 0.0, maxX };
            double[] y = { 0.0, 300.0 };
            pp.AbscissaData = x;
            pp.OrdinateData = y;

            plotSurface.Add(pp);

            plotSurface.XAxis1.Label    = xLabel;
            plotSurface.XAxis1.WorldMin = 0.0;
            plotSurface.XAxis1.WorldMax = maxX;

            plotSurface.YAxis1.Label    = "Temperature (Deg K)";
            plotSurface.YAxis1.WorldMin = yMin;
            plotSurface.YAxis1.WorldMax = yMax;

            plotSurface.Refresh();
        }
Exemple #22
0
        public void InitDataToChart()
        {
            //图例
            legend = new Legend();
            legend.AttachTo(PlotSurface2D.XAxisPosition.Top, PlotSurface2D.YAxisPosition.Left);
            legend.VerticalEdgePlacement   = Legend.Placement.Inside;
            legend.HorizontalEdgePlacement = Legend.Placement.Outside;
            legend.YOffset                 = -5;
            legend.BorderStyle             = LegendBase.BorderType.Line;
            legend.NumberItemsHorizontally = 2;
            legend.Font          = new Font(FontFamily.GenericSerif, 8, FontStyle.Regular);
            legend.AutoScaleText = false;
            //网格
            grid = new Grid();
            grid.HorizontalGridType = Grid.GridType.Fine;
            grid.VerticalGridType   = Grid.GridType.Fine;
            grid.MajorGridPen.Color = Color.Silver;
            grid.MinorGridPen.Color = Color.Silver;
            /////////////////////////////////////////////
            //直线图
            linePlot = new LinePlot();
            linePlot.OrdinateData = cart.regressY;
            linePlot.AbscissaData = xList;
            linePlot.Color        = Color.Orange;
            linePlot.Pen.Width    = 2.0f;
            //点图
            Marker marker = new Marker(Marker.MarkerType.FilledCircle, 3, new Pen(Color.Blue));

            marker.FillBrush       = new SolidBrush(Color.RoyalBlue);
            pointPlot              = new PointPlot(marker);
            pointPlot.AbscissaData = xList;
            pointPlot.OrdinateData = yList;
            pointPlot.ShowInLegend = false;
            if (cart.regressXYB > 0)
            {
                linePlot.Label = yLabel + "=" + cart.regressXYA.ToString("F2") + "*" + xLabel + "+" + cart.regressXYB.ToString("F2")
                                 + ",R=" + cart.correlationXY.ToString("F2");
            }
            else
            {
                linePlot.Label = yLabel + "=" + cart.regressXYA.ToString("F2") + "*" + xLabel + cart.regressXYB.ToString("F2")
                                 + ",R=" + cart.correlationXY;
            }
            label1.Text = xLabel + "(m:" + cart.xMean.ToString("F1") + ",s':" + cart.xVar.ToString("F1")
                          + ")  " + yLabel + "(m:" + cart.yMean.ToString("F1") + ",s':" + cart.yVar.ToString("F1") + ")";
            //添加
            chart.Add(grid);
            chart.Add(linePlot);
            chart.Add(pointPlot);
            //设置属性
            chart.XAxis1.Label = xLabel + ":" + xUnit;
            chart.YAxis1.Label = yLabel + ":" + yUnit;
            chart.YAxis1.LabelOffsetAbsolute = true;
            chart.Padding = 5;
            chart.AddInteraction(new xuzhenzhen.com.chart.Windows.PlotSurface2D.Interactions.VerticalGuideline());
            chart.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));
            chart.PlotBackColor = Color.White;
            chart.BackColor     = System.Drawing.SystemColors.Control;
            chart.XAxis1.Color  = Color.Black;
            chart.YAxis1.Color  = Color.Black;
            chart.Legend        = legend;
            chart.LegendZOrder  = 1;
            chart.Refresh();
        }
Exemple #23
0
        public LabelPointPlotSample()
        {
            infoText  = "";
            infoText += "Cs2Te Photocathode QE evolution Example. Demonstrates - \n";
            infoText += "  * LabelPointPlot (allows text to be associated with points) \n";
            infoText += "  * PointPlot droplines \n";
            infoText += "  * LabelAxis \n";
            infoText += "  * PhysicalSpacingMin property of LabelAxis \n";

            qeExampleTimerEnabled = true;
            plotCanvas.Clear();

            int len = 24;

            string[] s = new string[len];
            PlotQEExampleValues     = new double[len];
            PlotQEExampleTextValues = new string[len];

            Random r = new Random();

            for (int i = 0; i < len; i++)
            {
                PlotQEExampleValues[i] = 8.0 + 12.0 * (double)r.Next(10000) / 10000.0;
                if (PlotQEExampleValues[i] > 18.0)
                {
                    PlotQEExampleTextValues[i] = "KCsTe";
                }
                else
                {
                    PlotQEExampleTextValues[i] = "";
                }
                s[i] = i.ToString("00") + ".1";
            }

            PointPlot pp = new PointPlot();

            pp.DataSource       = PlotQEExampleValues;
            pp.Marker           = new Marker(Marker.MarkerType.Square, 10);
            pp.Marker.DropLine  = true;
            pp.Marker.LineColor = Colors.CornflowerBlue;
            pp.Marker.Filled    = false;
            plotCanvas.Add(pp);

            LabelPointPlot tp1 = new LabelPointPlot();

            tp1.DataSource        = PlotQEExampleValues;
            tp1.TextData          = PlotQEExampleTextValues;
            tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above;
            tp1.Marker            = new Marker(Marker.MarkerType.None, 10);
            plotCanvas.Add(tp1);

            LabelAxis la = new LabelAxis(plotCanvas.XAxis1);

            for (int i = 0; i < len; ++i)
            {
                la.AddLabel(s[i], i);
            }
            Font ff = Font.FromName("Verdana");

            la.TickTextFont       = ff.WithSize(7);
            la.PhysicalSpacingMin = 25;
            plotCanvas.XAxis1     = la;

            plotCanvas.Title               = "Cs2Te Photocathode QE evolution";
            plotCanvas.TitleFont           = ff.WithSize(15);
            plotCanvas.XAxis1.WorldMin     = -1.0;
            plotCanvas.XAxis1.WorldMax     = len;
            plotCanvas.XAxis1.LabelFont    = ff.WithSize(10);
            plotCanvas.XAxis1.Label        = "Cathode ID";
            plotCanvas.YAxis1.Label        = "QE [%]";
            plotCanvas.YAxis1.LabelFont    = ff.WithSize(10);
            plotCanvas.YAxis1.TickTextFont = ff.WithSize(10);

            plotCanvas.YAxis1.WorldMin      = 0.0;
            plotCanvas.YAxis1.WorldMax      = 25.0;
            plotCanvas.XAxis1.TickTextAngle = 60.0;

            // Add timer into Xwt loop for data updates
            Application.TimeoutInvoke(750, qeExampleTimer_Tick);

            PackStart(plotCanvas.Canvas, true);
            Label info = new Label(infoText);

            PackStart(info);
        }
Exemple #24
0
        public PlotQE()
        {
            infoText  = "";
            infoText += "Cs2Te Photocathode QE evolution Example. Demonstrates - \n";
            infoText += "  * LabelPointPlot (allows text to be associated with points) \n";
            infoText += "  * PointPlot droplines \n";
            infoText += "  * LabelAxis \n";
            infoText += "  * PhysicalSpacingMin property of LabelAxis \n";
            infoText += "You cannot interact with this chart";

            // This doesn't currently work, as the Timer is not in a Window
            qeExampleTimer          = new System.Windows.Forms.Timer();
            qeExampleTimer.Interval = 500;
            qeExampleTimer.Tick    += new EventHandler(qeExampleTimer_Tick);
            qeExampleTimerEnabled   = true;

            plotSurface.Clear();

            int len = 24;

            string[] s = new string[len];
            PlotQEExampleValues     = new double[len];
            PlotQEExampleTextValues = new string[len];

            Random r = new Random();

            for (int i = 0; i < len; i++)
            {
                PlotQEExampleValues[i] = 8.0f + 12.0f * (double)r.Next(10000) / 10000.0f;
                if (PlotQEExampleValues[i] > 18.0f)
                {
                    PlotQEExampleTextValues[i] = "KCsTe";
                }
                else
                {
                    PlotQEExampleTextValues[i] = "";
                }
                s[i] = i.ToString("00") + ".1";
            }

            PointPlot pp = new PointPlot();

            pp.DataSource      = PlotQEExampleValues;
            pp.Marker          = new Marker(Marker.MarkerType.Square, 10);
            pp.Marker.DropLine = true;
            pp.Marker.Pen      = Pens.CornflowerBlue;
            pp.Marker.Filled   = false;
            plotSurface.Add(pp);

            LabelPointPlot tp1 = new LabelPointPlot();

            tp1.DataSource        = PlotQEExampleValues;
            tp1.TextData          = PlotQEExampleTextValues;
            tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above;
            tp1.Marker            = new Marker(Marker.MarkerType.None, 10);
            plotSurface.Add(tp1);

            LabelAxis la = new LabelAxis(plotSurface.XAxis1);

            for (int i = 0; i < len; ++i)
            {
                la.AddLabel(s[i], i);
            }
            FontFamily ff = new FontFamily("Verdana");

            la.TickTextFont       = new Font(ff, 7);
            la.PhysicalSpacingMin = 25;
            plotSurface.XAxis1    = la;

            plotSurface.Title               = "Cs2Te Photocathode QE evolution";
            plotSurface.TitleFont           = new Font(ff, 15);
            plotSurface.XAxis1.WorldMin     = -1.0f;
            plotSurface.XAxis1.WorldMax     = len;
            plotSurface.XAxis1.LabelFont    = new Font(ff, 10);
            plotSurface.XAxis1.Label        = "Cathode ID";
            plotSurface.YAxis1.Label        = "QE [%]";
            plotSurface.YAxis1.LabelFont    = new Font(ff, 10);
            plotSurface.YAxis1.TickTextFont = new Font(ff, 10);

            plotSurface.YAxis1.WorldMin = 0.0;
            plotSurface.YAxis1.WorldMax = 25.0;

            plotSurface.XAxis1.TicksLabelAngle = 60.0f;

            plotSurface.Refresh();
        }
Exemple #25
0
        public FinancialDemo() : base("Multiple linked plot demo")
        {
            //
            // Gtk Window Setup
            //
            InitializeComponent();

            costPS.Clear();

            // obtain stock information from xml file
            DataSet ds = new DataSet();

            System.IO.Stream file =
                Assembly.GetExecutingAssembly().GetManifestResourceStream("GtkTest.Resources.asx_jbh.xml");
            ds.ReadXml(file, System.Data.XmlReadMode.ReadSchema);
            DataTable dt = ds.Tables[0];
            // DataView dv = new DataView(dt);

            // create CandlePlot.
            CandlePlot cp = new CandlePlot();

            cp.DataSource        = dt;
            cp.AbscissaData      = "Date";
            cp.OpenData          = "Open";
            cp.LowData           = "Low";
            cp.HighData          = "High";
            cp.CloseData         = "Close";
            cp.BearishColor      = Color.Red;
            cp.BullishColor      = Color.Green;
            cp.Style             = CandlePlot.Styles.Filled;
            costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            costPS.Add(new Grid());
            costPS.Add(cp);
            costPS.Title                      = "AU:JBH";
            costPS.YAxis1.Label               = "Price [$]";
            costPS.YAxis1.LabelOffset         = 40;
            costPS.YAxis1.LabelOffsetAbsolute = true;
            costPS.XAxis1.HideTickText        = true;
            costPS.SurfacePadding             = 5;

            costPS.AddInteraction(new NPlot.PlotDrag(true, true));
            costPS.AddInteraction(new NPlot.AxisDrag());
            costPS.InteractionOccurred += new NPlot.InteractivePlotSurface2D.InteractionHandler(costPS_InteractionOccurred);
            costPS.AddAxesConstraint(new AxesConstraint.Position(YAxisPosition.Left, 60));

            costPS.Refresh();

            PointPlot pp = new PointPlot();

            pp.Marker          = new Marker(Marker.MarkerType.Square, 0);
            pp.Marker.Pen      = new Pen(Color.Red, 5.0f);
            pp.Marker.DropLine = true;
            pp.DataSource      = dt;
            pp.AbscissaData    = "Date";
            pp.OrdinateData    = "Volume";
            volumePS.Add(pp);
            volumePS.YAxis1.Label = "Volume";
            volumePS.YAxis1.LabelOffsetAbsolute = true;
            volumePS.YAxis1.LabelOffset         = 40;
            volumePS.SurfacePadding             = 5;

            volumePS.AddAxesConstraint(new AxesConstraint.Position(YAxisPosition.Left, 60));
            volumePS.AddInteraction(new NPlot.AxisDrag());
            volumePS.AddInteraction(new NPlot.PlotDrag(true, false));
            volumePS.InteractionOccurred += new NPlot.InteractivePlotSurface2D.InteractionHandler(volumePS_InteractionOccurred);
            volumePS.PreRefresh          += new NPlot.InteractivePlotSurface2D.PreRefreshHandler(volumePS_PreRefresh);

            volumePS.Refresh();
        }
Exemple #26
0
        public static void Run(InteractiveHost plot)
        {
            // All the toolkit specific code does is one of these lines:
            // InteractiveHost plot = new Florence.GtkSharp.InteractiveHost();
            // InteractiveHost plot = new Florence.WinForms.InteractiveHost();

            // Start the interactive host; this starts up a GUI thread
            // and otherwise gets the GUI ready to go.
            plot.Start();


            // Generate some data to plot!
            var rand = new Random(0);

            var x = new double[100];

            for (int ii = 0; ii < x.Length; ++ii)
            {
                x[ii] = rand.NextNormal(0.0, 1.0);
            }

            var y = new double[x.Length];

            for (int ii = 0; ii < y.Length; ++ii)
            {
                y[ii] = 2.0 + 3.0 * x[ii] + rand.NextNormal(0.0, 2.5);
            }

            var t = new DateTime[15];
            var s = new double[t.Length];

            t[0] = new DateTime(2013, 12, 1);
            s[0] = 100.0;

            for (int ii = 1; ii < t.Length; ++ii)
            {
                t[ii] = t[ii - 1].AddDays(1);
                s[ii] = s[ii - 1] * Math.Exp(rand.NextNormal(0.05 / 365.0, 0.15 / Math.Sqrt(365.0)));
            }


            // Create our first plot
            var plot1 = new PointPlot()
            {
                AbscissaData = x, OrdinateData = y
            };

            plot.Add(plot1);
            plot.XAxis1.Label = "Love of Graphs";
            plot.YAxis1.Label = "Overall Awesomeness";
            plot.Title        = "Effect of Graph Affinity on Overall Awesomeness";

            // Pause execution. In an interactive environment, (C#/F# REPL) this would not be necessary
            Console.ReadLine();

            // Try putting your mouse over the numbers on either the X or Y axis,
            // pressing the mouse button then dragging left and right (for the X)
            // or up and down (for the Y).

            // Now try clicking and dragging in the main plot area.

            // Now press enter, to move on to the next example

            plot.newFigure();
            plot.Title = "A new one!";

            Console.ReadLine();

            plot.previous();
            plot.Title = "First one again!";

            Console.ReadLine();

            plot.next();
            plot.closeFigure();

            var line_plot = plot.newFigure();

            line_plot.Add(new LinePlot()
            {
                AbscissaData = t, OrdinateData = s
            });

            //var plot2 = new LinePlot() { AbscissaData = x, OrdinateData = y };
            //plot.Title = "Test Plot 2";
            //plot.XAxis1.Label = "X2";
            //plot.YAxis1.Label = "Y2";
            //plot.Add(plot2);

            Console.ReadLine();

            plot.Stop();
        }
Exemple #27
0
        public PlotParticles()
        {
            infoText  = "";
            infoText += "Particles Example. Demonstrates - \n";
            infoText += " * How to chart multiple data sets against multiple axes at the same time.";

            plotSurface.Clear();

            Grid mygrid = new Grid();

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

            // in this example we synthetize a particle distribution
            // in the x-x' phase space and plot it, with the rms Twiss
            // ellipse and desnity distribution
            const int Particle_Number = 500;

            float [] x = new float[Particle_Number];
            float [] y = new float[Particle_Number];
            // Twiss parameters for the beam ellipse
            // 5 mm mrad max emittance, 1 mm beta function
            float alpha, beta, gamma, emit;

            alpha = -2.0f;
            beta  = 1.0f;
            gamma = (1.0f + alpha * alpha) / beta;
            emit  = 4.0f;

            float da, xmax, xpmax;

            da    = -alpha / gamma;
            xmax  = (float)Math.Sqrt(emit / gamma);
            xpmax = (float)Math.Sqrt(emit * gamma);

            Random rand = new Random();

            // cheap randomizer on the unit circle
            for (int i = 0; i < Particle_Number; i++)
            {
                float r;
                do
                {
                    x[i] = (float)(2.0f * rand.NextDouble() - 1.0f);
                    y[i] = (float)(2.0f * rand.NextDouble() - 1.0f);
                    r    = (float)Math.Sqrt(x[i] * x[i] + y[i] * y[i]);
                } while (r > 1.0f);
            }

            // transform to the tilted twiss ellipse
            for (int i = 0; i < Particle_Number; ++i)
            {
                y[i] *= xpmax;
                x[i]  = x[i] * xmax + y[i] * da;
            }
            plotSurface.Title = "Beam Horizontal Phase Space and Twiss ellipse";

            PointPlot pp = new PointPlot();

            pp.OrdinateData = y;
            pp.AbscissaData = x;
            pp.Marker       = new Marker(Marker.MarkerType.FilledCircle, 4, new Pen(Color.Blue));
            plotSurface.Add(pp, XAxisPosition.Bottom, YAxisPosition.Left);

            // set axes
            LinearAxis lx = (LinearAxis)plotSurface.XAxis1;

            lx.Label = "Position - x [mm]";
            lx.NumberOfSmallTicks = 2;
            LinearAxis ly = (LinearAxis)plotSurface.YAxis1;

            ly.Label = "Divergence - x' [mrad]";
            ly.NumberOfSmallTicks = 2;

            // Draws the rms Twiss ellipse computed from the random data
            float [] xeli = new float [40];
            float [] yeli = new float [40];

            float a_rms, b_rms, g_rms, e_rms;

            Twiss(x, y, out a_rms, out b_rms, out g_rms, out e_rms);
            TwissEllipse(a_rms, b_rms, g_rms, e_rms, ref xeli, ref yeli);

            LinePlot lp = new LinePlot();

            lp.OrdinateData = yeli;
            lp.AbscissaData = xeli;
            plotSurface.Add(lp, XAxisPosition.Bottom, YAxisPosition.Left);
            lp.Pen = new Pen(Color.Red, 2.0f);
            // Draws the ellipse containing 100% of the particles
            // for a uniform distribution in 2D the area is 4 times the rms
            float [] xeli2 = new float [40];
            float [] yeli2 = new float [40];
            TwissEllipse(a_rms, b_rms, g_rms, 4.0F * e_rms, ref xeli2, ref yeli2);

            LinePlot lp2 = new LinePlot();

            lp2.OrdinateData = yeli2;
            lp2.AbscissaData = xeli2;
            plotSurface.Add(lp2, XAxisPosition.Bottom, YAxisPosition.Left);
            Pen p2 = new Pen(Color.Red, 2.0f);

            float [] pattern = { 5.0f, 40.0f };
            p2.DashPattern = pattern;
            lp2.Pen        = p2;

            // now bin the particle position to create beam density histogram
            float range, min, max;

            min   = (float)lx.WorldMin;
            max   = (float)lx.WorldMax;
            range = max - min;

            const int Nbin = 30;

            float [] xbin = new float[Nbin + 1];
            float [] xh   = new float[Nbin + 1];

            for (int j = 0; j <= Nbin; ++j)
            {
                xbin[j] = min + j * range;
                if (j < Nbin)
                {
                    xh[j] = 0.0F;
                }
            }
            for (int i = 0; i < Particle_Number; ++i)
            {
                if (x[i] >= min && x[i] <= max)
                {
                    int j;
                    j      = Convert.ToInt32(Nbin * (x[i] - min) / range);
                    xh[j] += 1;
                }
            }
            StepPlot sp = new StepPlot();

            sp.OrdinateData = xh;
            sp.AbscissaData = new StartStep(min, range / Nbin);
            sp.Center       = true;
            plotSurface.Add(sp, XAxisPosition.Bottom, YAxisPosition.Right);
            // axis formatting
            LinearAxis ly2 = (LinearAxis)plotSurface.YAxis2;

            ly2.WorldMin           = 0.0f;
            ly2.Label              = "Beam Density [a.u.]";
            ly2.NumberOfSmallTicks = 2;
            sp.Pen = new Pen(Color.Green, 2);

            // Finally, refreshes the plot
            plotSurface.Refresh();
        }
Exemple #28
0
        public void quote()
        {
            if (!RandomDate.CheckDate(dateTimePicker1.Value))
            {
                comboBox1.InvokeIfRequired(() => {
                    comboBox1.Enabled = true;
                });

                button1.InvokeIfRequired(() =>
                {
                    button1.Enabled = true;
                });

                dataGridView1.InvokeIfRequired(() =>
                {
                    dateTimePicker1.Enabled = true;
                });
                MessageBox.Show("No Data");
                NPlot.PointPlot p = new PointPlot();
                p.Marker.Type = Marker.MarkerType.Circle;
                return;
            }
            using (StreamReader sr = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\TXF\\" + dateTimePicker1.Value.ToString("MM-dd-yyyy") + "TXF.TXT"))
            {
                string[] wordss = sr.ReadToEnd().Split('\n');
                bool     istart = false;

                string date = "";
                dateTimePicker1.InvokeIfRequired(() => {
                    date = dateTimePicker1.Value.ToString("yyyy/M/d");
                });

                foreach (string words in wordss)
                {
                    if (words == "")
                    {
                        break;
                    }
                    string[] word = words.Split(',');

                    //search start
                    if (word[1].Length < 6)
                    {
                        return;
                    }
                    if (word[1].Substring(0, 6) == "084500")
                    {
                        istart = true;
                    }
                    if (int.Parse(word[1].Substring(0, 4)) > 1344)
                    {
                        break;
                    }
                    if (!istart)
                    {
                        continue;
                    }

                    //MK
                    MKdata.Add(word[1], word[4], word[5], word[6]);
                    DKdata.Add(date, word[4], word[5], word[6]);
                    mACD.macd(MKdata.kdata);

                    //run
                    int ss = times.tDiff(word[1]);
                    if (ss > 0)
                    {
                        Thread.Sleep(ss);
                    }
                }
            }


            comboBox1.InvokeIfRequired(() => {
                comboBox1.Enabled = true;
            });

            button1.InvokeIfRequired(() =>
            {
                button1.Enabled = true;
            });

            dataGridView1.InvokeIfRequired(() =>
            {
                dateTimePicker1.Enabled = true;
            });

            T_Quote.Abort();
        }
Exemple #29
0
        public FinancialDemo()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            costPS.Clear();
            costPS.DateTimeToolTip = true;

            // obtain stock information from xml file
            DataSet ds = new DataSet();

            using (StringReader sr = new StringReader(Resources.asx_jbh))
                ds.ReadXml(sr, System.Data.XmlReadMode.ReadSchema);
            DataTable dt = ds.Tables[0];
            DataView  dv = new DataView(dt);

            // create CandlePlot.
            CandlePlot cp = new CandlePlot();

            cp.DataSource        = dt;
            cp.AbscissaData      = "Date";
            cp.OpenData          = "Open";
            cp.LowData           = "Low";
            cp.HighData          = "High";
            cp.CloseData         = "Close";
            cp.BearishColor      = Color.Red;
            cp.BullishColor      = Color.Green;
            cp.Style             = CandlePlot.Styles.Filled;
            costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            costPS.Add(new Grid());
            costPS.Add(cp);
            costPS.Title                      = "AU:JBH";
            costPS.YAxis1.Label               = "Price [$]";
            costPS.YAxis1.LabelOffset         = 40;
            costPS.YAxis1.LabelOffsetAbsolute = true;
            costPS.XAxis1.HideTickText        = true;
            costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());
            costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
            costPS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(costPS_InteractionOccured);
            costPS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));

            PointPlot pp = new PointPlot();

            pp.Marker          = new Marker(Marker.MarkerType.Square, 0);
            pp.Marker.Pen      = new Pen(Color.Red, 5.0f);
            pp.Marker.DropLine = true;
            pp.DataSource      = dt;
            pp.AbscissaData    = "Date";
            pp.OrdinateData    = "Volume";
            volumePS.Add(pp);
            volumePS.YAxis1.Label = "Volume";
            volumePS.YAxis1.LabelOffsetAbsolute = true;
            volumePS.YAxis1.LabelOffset         = 40;
            volumePS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));
            volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false));
            volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
            volumePS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(volumePS_InteractionOccured);
            volumePS.PreRefresh         += new NPlot.Windows.PlotSurface2D.PreRefreshHandler(volumePS_PreRefresh);

            this.costPS.RightMenu = new ReducedContextMenu();
        }
Exemple #30
0
        public void CreatePlot()
        {
            costPS.Clear();
            //costPS.DateTimeToolTip = true;

            // obtain stock information from xml file
            DataSet ds = new DataSet();

            System.IO.Stream file =
                Assembly.GetExecutingAssembly().GetManifestResourceStream("DemoLib.Resources.asx_jbh.xml");
            ds.ReadXml(file, System.Data.XmlReadMode.ReadSchema);
            DataTable dt = ds.Tables[0];
            DataView  dv = new DataView(dt);

            // create CandlePlot.
            CandlePlot cp = new CandlePlot();

            cp.DataSource        = dt;
            cp.AbscissaData      = "Date";
            cp.OpenData          = "Open";
            cp.LowData           = "Low";
            cp.HighData          = "High";
            cp.CloseData         = "Close";
            cp.BearishColor      = Color.Red;
            cp.BullishColor      = Color.Green;
            cp.Style             = CandlePlot.Styles.Filled;
            costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            costPS.Add(new Grid());
            costPS.Add(cp);
            costPS.Title                      = "AU:JBH";
            costPS.YAxis1.Label               = "Price [$]";
            costPS.YAxis1.LabelOffset         = 40;
            costPS.YAxis1.LabelOffsetAbsolute = true;
            costPS.XAxis1.HideTickText        = true;
            costPS.SurfacePadding             = 5;
            costPS.AddInteraction(new PlotDrag(true, true));
            costPS.AddInteraction(new AxisDrag());
            costPS.InteractionOccurred += costPS_InteractionOccured;
            costPS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));

            PointPlot pp = new PointPlot();

            pp.Marker          = new Marker(Marker.MarkerType.Square, 0);
            pp.Marker.Pen      = new Pen(Color.Red, 5.0f);
            pp.Marker.DropLine = true;
            pp.DataSource      = dt;
            pp.AbscissaData    = "Date";
            pp.OrdinateData    = "Volume";
            volumePS.Add(pp);
            volumePS.YAxis1.Label = "Volume";
            volumePS.YAxis1.LabelOffsetAbsolute = true;
            volumePS.YAxis1.LabelOffset         = 40;
            volumePS.SurfacePadding             = 5;
            volumePS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60));
            volumePS.AddInteraction(new AxisDrag());
            volumePS.AddInteraction(new PlotDrag(true, false));
            volumePS.InteractionOccurred += volumePS_InteractionOccured;
            volumePS.PreRefresh          += volumePS_PreRefresh;

            //this.costPS.RightMenu = new ReducedContextMenu();
        }