Ejemplo n.º 1
0
        public void ExecuteRecipe(Plot plt)
        {
            ScottPlot.Alignment[] alignments = (ScottPlot.Alignment[])Enum.GetValues(typeof(ScottPlot.Alignment));

            for (int i = 0; i < alignments.Length; i++)
            {
                double frac = (double)i / alignments.Length;
                double x    = Math.Sin(frac * Math.PI * 2);
                double y    = Math.Cos(frac * Math.PI * 2);

                var txt = plt.AddText(alignments[i].ToString(), x, y);
                txt.Alignment       = alignments[i];
                txt.Font.Color      = Color.Black;;
                txt.BackgroundColor = Color.LightSteelBlue;
                txt.BackgroundFill  = true;
                txt.Rotation        = 5;
                txt.BorderSize      = 2;
                txt.BorderColor     = Color.Navy;
                txt.DragEnabled     = true;

                plt.AddPoint(x, y, Color.Red, 10);
            }

            plt.Margins(.5, .2);
        }
Ejemplo n.º 2
0
        public void ExecuteRecipe(Plot plt)
        {
            // display some interesting data in the background
            plt.AddSignal(DataGen.Sin(51), label: "sin");
            plt.AddSignal(DataGen.Cos(51), label: "cos");

            // add text with custom fonts
            plt.AddText("very graph", 25, .8, new Drawing.Font()
            {
                Name = "comic sans ms", Size = 24, Color = Color.Blue, Bold = true
            });
            plt.AddText("so data", 0, 0, new Drawing.Font()
            {
                Name = "comic sans ms", Size = 42, Color = Color.Magenta, Bold = true
            });
            plt.AddText("many documentation", 3, -.6, new Drawing.Font()
            {
                Name = "comic sans ms", Size = 18, Color = Color.DarkBlue, Bold = true
            });
            plt.AddText("wow.", 10, .6, new Drawing.Font()
            {
                Name = "comic sans ms", Size = 36, Color = Color.Green, Bold = true
            });
            plt.AddText("NuGet", 32, 0, new Drawing.Font()
            {
                Name = "comic sans ms", Size = 24, Color = Color.Gold, Bold = true
            });

            // configure axis labels
            plt.YAxis.Label(label: "vertical units", fontName: "impact", size: 24, color: Color.Red, bold: true);
            plt.XAxis.Label(label: "horizontal units", fontName: "georgia", size: 24, color: Color.Blue, bold: true);
            plt.XAxis2.Label(label: "Impressive Graph", size: 24, color: Color.Purple, bold: true);

            // configure tick labels
            plt.XAxis.TickLabelStyle(color: Color.DarkBlue, fontName: "comic sans ms", fontSize: 16);
            plt.YAxis.TickLabelStyle(color: Color.DarkGreen, fontName: "comic sans ms", fontSize: 16);

            // add a legend to the corner
            var legend = plt.Legend();

            legend.FontName  = "comic sans ms";
            legend.FontSize  = 18;
            legend.FontBold  = true;
            legend.FontColor = Color.DarkBlue;
        }
Ejemplo n.º 3
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddColorbar(Drawing.Colormap.Turbo);

            // direct attention to the colorbar
            var text = plt.AddText("Colorbar", 5, 0, 24, Color.Red);

            text.Alignment = Alignment.MiddleRight;
            plt.AddArrow(7, 0, 5, 0, color: Color.Red);
            plt.SetAxisLimits(-10, 10, -10, 10);
        }
Ejemplo n.º 4
0
        public void ExecuteRecipe(Plot plt)
        {
            int pointCount = 51;

            double[] x   = DataGen.Consecutive(pointCount);
            double[] sin = DataGen.Sin(pointCount);
            double[] cos = DataGen.Cos(pointCount);

            plt.AddScatter(x, sin);
            plt.AddScatter(x, cos);

            plt.AddText("sample text", 10, .5, size: 16, color: Color.Blue);
        }
Ejemplo n.º 5
0
        public void ExecuteRecipe(Plot plt)
        {
            var cb = plt.AddColorbar(Drawing.Colormap.Turbo);

            cb.MinValue     = -10;
            cb.MaxValue     = 10;
            cb.MinIsClipped = true;
            cb.MaxIsClipped = true;

            // direct attention to the colorbar
            var text = plt.AddText("Colorbar", 5, 0, 24, Color.Red);

            text.Alignment = Alignment.MiddleRight;
            plt.AddArrow(7, 0, 5, 0, color: Color.Red);
            plt.SetAxisLimits(-10, 10, -10, 10);
        }
Ejemplo n.º 6
0
        public void ExecuteRecipe(Plot plt)
        {
            var cb = plt.AddColorbar(Drawing.Colormap.Turbo);

            // Add manual ticks (disabling automatic ticks)
            cb.AddTick(0, "-123");
            cb.AddTick(1, "+123");
            cb.AddTick(.5, "0");
            cb.AddTick(.25, "-61.5");
            cb.AddTick(.75, "+61.5");

            // To re-enable automatic ticks call cb.AutomaticTicks(true)

            // direct attention to the colorbar
            var text = plt.AddText("Colorbar", 5, 0, 24, Color.Red);

            text.Alignment = Alignment.MiddleRight;
            plt.AddArrow(7, 0, 5, 0, color: Color.Red);
            plt.SetAxisLimits(-10, 10, -10, 10);
        }
Ejemplo n.º 7
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand       = new(0);
            int    pointCount = 30;

            double[] xs        = DataGen.Consecutive(pointCount);
            double[] ys        = DataGen.Random(rand, pointCount, 10);
            string[] labels    = ys.Select(x => x.ToString("N2")).ToArray();
            var      labelFont = new Drawing.Font
            {
                Bold      = true,
                Color     = Color.Black,
                Alignment = Alignment.MiddleCenter
            };

            var myBubblePlot = plt.AddBubblePlot();

            for (int i = 0; i < xs.Length; i++)
            {
                // give each bubble a random size and make smaller ones bluer
                double randomValue = rand.NextDouble();
                double bubbleSize  = randomValue * 30 + 10;
                Color  bubbleColor = Drawing.Colormap.Jet.GetColor(randomValue, .5);

                myBubblePlot.Add(
                    x: xs[i],
                    y: ys[i],
                    radius: bubbleSize,
                    fillColor: bubbleColor,
                    edgeColor: Color.Transparent,
                    edgeWidth: 1
                    );

                plt.AddText(labels[i], xs[i], ys[i], labelFont);
            }

            plt.Title("Bubble Plot with Labels");
            plt.AxisAuto(.2, .25); // zoom out to accommodate large bubbles
        }
Ejemplo n.º 8
0
        public void ExecuteRecipe(Plot plt)
        {
            int pointCount = 51;

            double[] x   = DataGen.Consecutive(pointCount);
            double[] sin = DataGen.Sin(pointCount);
            double[] cos = DataGen.Cos(pointCount);

            plt.AddScatter(x, sin);
            plt.AddScatter(x, cos);

            plt.AddPoint(25, 0.8, color: Color.Green);
            var t1 = plt.AddText(" Important Point (1)", 25, 0.8, 16, Color.Green);

            plt.AddPoint(30, 0.3, color: Color.Black, size: 15);
            var t2 = plt.AddText(" Default alignment (2)", 30, 0.3, 16);

            plt.AddPoint(30, 0, color: Color.Black, size: 15);
            var t3 = plt.AddText("Middle center (3)", 30, 0, 16);

            t3.Alignment = Alignment.MiddleCenter;

            plt.AddPoint(30, -0.3, color: Color.Black, size: 15);
            var t4 = plt.AddText("Upper left (4)", 30, -0.3, 16);

            t4.Alignment = Alignment.UpperLeft;

            plt.AddPoint(5, -.5, color: Color.Blue, size: 15);
            var t5 = plt.AddText(" Rotated Text (5)", 5, -.5, 16);

            t5.Rotation = -30;

            var t6 = plt.AddText(" Filled Background (6)", 15, -.6, 16);

            t6.Color           = Color.Red;
            t6.FontBold        = true;
            t6.BackgroundFill  = true;
            t6.BackgroundColor = Color.LightBlue;
        }