Exemplo n.º 1
0
            public void Render(Plot plt)
            {
                // generate sample data to plot
                Random rand       = new Random(0);
                int    pointCount = 100;

                double[] xs        = DataGen.Consecutive(pointCount);
                double[] rainfall  = DataGen.RandomWalk(rand, pointCount, 1, 10);       // small values
                double[] organisms = DataGen.RandomWalk(rand, pointCount, 1000, 20000); // large values

                // customize the primary X axis
                plt.XAxis.Label = "Days After Volcano Eruption";

                // add a scatter plot and customize the primary Y axis
                var scatter1 = plt.PlotScatter(xs, rainfall);

                plt.YAxis.Label = "Daily Rainfall (cm)";
                plt.YAxis.Color = scatter1.color;

                // add another scatter plot but give it a custom vertical axis index
                var scatter2 = plt.PlotScatter(xs, organisms);

                scatter2.VerticalAxisIndex = 3;

                // add a new vertical axis using same axis index as the second scatter plot
                var yAxis3 = plt.AddAxis(Renderable.Edge.Left, axisIndex: 3);

                yAxis3.Label = "Number of Organisms";
                yAxis3.Color = scatter2.color;
            }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var customCulture = new System.Globalization.CultureInfo("en-NZ");

            customCulture.DateTimeFormat.ShortDatePattern        = "yyyy-MM-dd";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            int width  = 800;
            int height = 600;
            var plot   = new Plot(width, height);

            DateTime[] myDates   = new DateTime[60];
            var        startdate = DateTime.Now;

            for (int i = 0; i < myDates.Length; i++)
            {
                myDates[i] = startdate.AddMinutes(i);
            }

            double[] dataX = myDates.Select(x => x.ToOADate()).ToArray();
            //plot.PlotScatter(dataX, dataY);

            plot.XAxis.DateTimeFormat(true);

            plot.YAxis.Label("°C");
            plot.YAxis.Color(Color.Red);

            plot.SetAxisLimitsY(0, 50);


            //double[] dataX = DataGen.Consecutive(60);
            double[] dataY = DataGen.Sin(60, 2, 25, 2);
            //plot.PlotScatter(dataX, dataY);

            var scatter = plot.AddScatter(dataX, dataY);

            scatter.LineWidth = 2;
            scatter.Color     = Color.Red;

            var baroScatter = plot.AddScatter(dataX, DataGen.Sin(60, 6, 1013, 4));

            var baroLimits = baroScatter.GetAxisLimits();


            var yAxis3 = plot.AddAxis(ScottPlot.Renderable.Edge.Left, axisIndex: 2);

            baroScatter.YAxisIndex = 2;
            yAxis3.Label("hPa");
            yAxis3.Color(baroScatter.Color);


            plot.SaveFig("out.png");
            var bitmap = plot.Render();
            var png    = ImageToPngByte(bitmap);


            Console.WriteLine($"PNG byte size is {png.Length}");
        }
Exemplo n.º 3
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot one set of data using the primary Y axis
            var sigSmall = plt.AddSignal(DataGen.Sin(51, mult: 1));
            sigSmall.YAxisIndex = 0;
            plt.YAxis.Label("Primary Axis");
            plt.YAxis.Color(sigSmall.Color);

            // plot another set of data using an additional axis
            var sigBig = plt.AddSignal(DataGen.Cos(51, mult: 100));
            var yAxis3 = plt.AddAxis(Renderable.Edge.Left, axisIndex: 2);
            sigBig.YAxisIndex = 2;
            yAxis3.Label("Additional Axis");
            yAxis3.Color(sigBig.Color);
        }