コード例 #1
0
        public PlottableScatterHighlight PlotScatterHighlight(
            double[] xs,
            double[] ys,
            Color?color                  = null,
            double lineWidth             = 1,
            double markerSize            = 5,
            string label                 = null,
            double[] errorX              = null,
            double[] errorY              = null,
            double errorLineWidth        = 1,
            double errorCapSize          = 3,
            MarkerShape markerShape      = MarkerShape.filledCircle,
            LineStyle lineStyle          = LineStyle.Solid,
            MarkerShape highlightedShape = MarkerShape.openCircle,
            Color?highlightedColor       = null,
            double?highlightedMarkerSize = null
            )
        {
            if (color is null)
            {
                color = settings.GetNextColor();
            }

            if (highlightedColor is null)
            {
                highlightedColor = Color.Red;
            }

            if (highlightedMarkerSize is null)
            {
                highlightedMarkerSize = 2 * markerSize;
            }

            PlottableScatterHighlight scatterPlot = new PlottableScatterHighlight(
                xs: xs,
                ys: ys,
                color: (Color)color,
                lineWidth: lineWidth,
                markerSize: markerSize,
                label: label,
                errorX: errorX,
                errorY: errorY,
                errorLineWidth: errorLineWidth,
                errorCapSize: errorCapSize,
                stepDisplay: false,
                markerShape: markerShape,
                lineStyle: lineStyle,
                highlightedShape: highlightedShape,
                highlightedColor: highlightedColor.Value,
                highlightedMarkerSize: highlightedMarkerSize.Value
                );

            Add(scatterPlot);
            return(scatterPlot);
        }
コード例 #2
0
        public PlottableScatterHighlight PlotScatterHighlight(
            double[] xs,
            double[] ys,
            Color?color                  = null,
            double lineWidth             = 1,
            double markerSize            = 5,
            string label                 = null,
            double[] errorX              = null,
            double[] errorY              = null,
            double errorLineWidth        = 1,
            double errorCapSize          = 3,
            MarkerShape markerShape      = MarkerShape.filledCircle,
            LineStyle lineStyle          = LineStyle.Solid,
            MarkerShape highlightedShape = MarkerShape.openCircle,
            Color?highlightedColor       = null,
            double?highlightedMarkerSize = null
            )
        {
            if (color is null)
            {
                color = settings.GetNextColor();
            }

            if (highlightedColor is null)
            {
                highlightedColor = Color.Red;
            }

            if (highlightedMarkerSize is null)
            {
                highlightedMarkerSize = 2 * markerSize;
            }

            var scatterPlot = new PlottableScatterHighlight(xs, ys, errorX, errorY)
            {
                color                 = (Color)color,
                lineWidth             = lineWidth,
                markerSize            = (float)markerSize,
                label                 = label,
                errorLineWidth        = (float)errorLineWidth,
                errorCapSize          = (float)errorCapSize,
                stepDisplay           = false,
                markerShape           = markerShape,
                lineStyle             = lineStyle,
                highlightedShape      = highlightedShape,
                highlightedColor      = highlightedColor.Value,
                highlightedMarkerSize = (float)highlightedMarkerSize.Value
            };

            Add(scatterPlot);
            return(scatterPlot);
        }
コード例 #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            vline = formsPlot1.plt.PlotVLine(1);
            hline = formsPlot1.plt.PlotHLine(1);

            formsPlot1.plt.PlotHSpan(10, 20, draggable: true);
            formsPlot1.plt.PlotVSpan(5, 10, draggable: true);

            Random rand = new Random(0);

            double[] xs = DataGen.Consecutive(100);
            double[] ys = DataGen.RandomWalk(rand, 100);
            sph = formsPlot1.plt.PlotScatterHighlight(xs, ys);

            formsPlot1.Render();
        }
コード例 #4
0
        public void PlotGraph(ScottPlotGraph graphModel)
        {
            var locationCount = GraphModel.LocationList.Count;
            var serviceCount  = GraphModel.TimeGraphUI.Count;
            var pointCount    = locationCount * serviceCount;

            scatterDataX = new double[pointCount + 1];
            scatterDataY = new double[pointCount + 1];
            highlightedTimeGraphUiModels = new TimeGraphUIModel[pointCount + 1];
            scatterIndex = 0;
            int i = 0;

            foreach (var graph in GraphModel.TimeGraphUI)
            {
                graph.Plot = PlotService(graphModel, graph, GraphModel.TimeGraphUI[i].ServiceAbbreviation);
                i++;
            }

            PlotTimeAxis(graphModel.Zoom, graphModel.Pan);
            PlotLocationAxis(graphModel);

            if (marker != null)
            {
                //redraw marker
                marker = TimetableGraph.plt.PlotScatter(marker.xs, marker.ys, Color.Red,
                                                        markerShape: MarkerShape.openCircle, markerSize: 15);
            }

            if (GraphModel.SelectedTimeGraph != null)
            {
                GraphModel.SelectedTimeGraph.Plot.lineWidth = 3;
            }

            TimetableGraph.plt.Style(figBg: GetResourceColor("WindowBackground"));
            TimetableGraph.plt.Style(dataBg: GetResourceColor("ControlBackground"));
            TimetableGraph.plt.Grid(enable: true, color: GetResourceColor("GridLine"));
            scatterHighLight = TimetableGraph.plt.PlotScatterHighlight(scatterDataX, scatterDataY, lineWidth: 0, markerSize: 0.5);
            TimetableGraph.Configure(enablePanning: false, enableScrollWheelZoom: false, enableRightClickZoom: false);
            TimetableGraph.Render();
        }
コード例 #5
0
        private void createScatterPlot()
        {
            double[] X   = dgrab.df[dgrab.df.IndexOfColumn("CalcX")].ToDoubleArray();
            double[] Y   = dgrab.df[dgrab.df.IndexOfColumn("CalcY")].ToDoubleArray();
            double[] col = dgrab.df[dgrab.df.IndexOfColumn("CLASSNUMBER")].ToDoubleArray();

            int    pointsPerPolygon = 100;
            double polyR            = dgrab.waferSize / 2;
            double polyX            = dgrab.xDieOri + dgrab.xCenter + xOffset;
            double polyY            = dgrab.yDieOri + dgrab.yCenter + yOffset;

            int markSize = 10;

            double[] xs = Enumerable.Range(0, pointsPerPolygon).Select(x => polyR * Math.Cos(2.0 * Math.PI * x / pointsPerPolygon) + polyX).ToArray();
            double[] ys = Enumerable.Range(0, pointsPerPolygon).Select(x => polyR * Math.Sin(2.0 * Math.PI * x / pointsPerPolygon) + polyY).ToArray();
            MainPlot.plt.PlotPolygon(xs, ys, lineColor: System.Drawing.Color.Black, fillColor: System.Drawing.Color.DarkGray);

            //This plots points that will be written over later. The reason we do this is because sph lets us highlight points we click on (and they need to be plotted this way)
            sph = MainPlot.plt.PlotScatterHighlight(X, Y, markerSize: markSize, lineWidth: 0, markerShape: MarkerShape.filledSquare);



            double offsetCenterX = dgrab.xCenter + xOffset;
            double offsetCenterY = dgrab.yCenter + yOffset;

            double offsetDieOriX = dgrab.xDieOri;
            double offsetDieOriY = dgrab.yDieOri;

            //Create the rectangles
            for (double x = offsetDieOriX + offsetCenterX - dgrab.waferSize / 2; x < offsetDieOriX + offsetCenterX + dgrab.waferSize / 2; x = x + dgrab.xDiePit)
            {
                for (double y = offsetDieOriY + offsetCenterY - dgrab.waferSize / 2; y < offsetDieOriY + offsetCenterY + dgrab.waferSize / 2; y = y + dgrab.yDiePit)
                {
                    if (isWithin(offsetCenterX, offsetCenterY, x, y, dgrab.xDiePit, dgrab.yDiePit))
                    {
                        MainPlot.plt.PlotPolygon(
                            xs: new double[] { x, x, x + dgrab.xDiePit, x + dgrab.xDiePit },
                            ys: new double[] { y, y + dgrab.yDiePit, y + dgrab.yDiePit, y },
                            lineWidth: 2, fillAlpha: .8, fillColor: System.Drawing.Color.Transparent,
                            lineColor: System.Drawing.Color.Black);
                    }
                }
            }
            //Draw the notch (WE DONT DRAW A TRIANGLE OR A SHAPE BECAUSE IT WOULD IMPLY THAT WE KNOW THE NOTCH SIZE WHICH WE DONT KNOW)
            MainPlot.plt.PlotArrow((dgrab.waferSize / 2 + dgrab.waferSize / 30) * Math.Sin(dgrab.notch) + offsetCenterX,
                                   (dgrab.waferSize / 2 + dgrab.waferSize / 30) * Math.Cos(dgrab.notch) + offsetCenterY,
                                   (dgrab.waferSize / 2) * Math.Sin(dgrab.notch) + offsetCenterX,
                                   (dgrab.waferSize / 2) * Math.Cos(dgrab.notch) + offsetCenterY);


            //Draw the color on the points
            for (int i = 0; i < X.Length; i++)
            {
                int r = 0;
                int b = 0;
                int g = 0;

                //Creates our color (if we don't get information on what color to use)
                HsvToRgb((int)col[i] % 125, 60, 45, out r, out g, out b);

                if (confg != null)
                {
                    try
                    {
                        System.Drawing.Color n = System.Drawing.ColorTranslator.FromHtml(confg.ht[("" + (int)col[i])]);
                        MainPlot.plt.PlotPoint(X[i], Y[i], markerSize: markSize, markerShape: MarkerShape.filledSquare, color: n);
                    }
                    catch (System.Collections.Generic.KeyNotFoundException)
                    {
                        MainPlot.plt.PlotPoint(X[i], Y[i], markerSize: markSize, markerShape: MarkerShape.filledSquare, color: System.Drawing.Color.FromArgb(r, g, b));
                    }
                }
                else
                {
                    MainPlot.plt.PlotPoint(X[i], Y[i], markerSize: markSize, markerShape: MarkerShape.filledSquare, color: System.Drawing.Color.FromArgb(r, g, b));
                }
            }
        }