예제 #1
0
        public static void PlotLineSeries(Plot plt, Colormap cmap)
        {
            int lineCount = 7;

            plt.Clear();
            for (int i = 0; i < lineCount; i++)
            {
                double   fraction = (double)i / lineCount;
                double[] ys       = DataGen.Sin(100, 2, mult: 1 + fraction * 2);
                Color    c        = cmap.GetColor(fraction);
                plt.PlotSignal(ys, color: c);
            }
            plt.AxisAuto();
        }
예제 #2
0
        private void MakePlot()
        {
            Colormap cmap = Colormap.Turbo;

            formsPlot1.plt.Clear();

            if (cbFirstColX.Checked)
            {
                if (cbSignal.Checked)
                {
                    // signal plots with spacing from first column
                    double dX = values[1, 0] - values[0, 0];

                    for (int y = 1; y < values.GetLength(1); y++)
                    {
                        double[] ys = new double[values.GetLength(0)];
                        for (int i = 0; i < values.GetLength(0); i++)
                        {
                            ys[i] = values[i, y];
                        }

                        Color?c = null;
                        if (cbAllColumns.Checked)
                        {
                            c = cmap.GetColor((double)y / values.GetLength(1));
                        }

                        if (cbAllColumns.Checked || nudColumn.Value == y)
                        {
                            formsPlot1.plt.PlotSignal(ys, sampleRate: 1 / dX, color: c);
                        }
                    }
                }
                else
                {
                    // individual scatter plots
                    double[] xs = new double[values.GetLength(0)];
                    for (int i = 0; i < values.GetLength(0); i++)
                    {
                        xs[i] = values[i, 0];
                    }

                    for (int y = 1; y < values.GetLength(1); y++)
                    {
                        double[] ys = new double[values.GetLength(0)];
                        for (int i = 0; i < values.GetLength(0); i++)
                        {
                            ys[i] = values[i, y];
                        }

                        Color?c = null;
                        if (cbAllColumns.Checked)
                        {
                            c = cmap.GetColor((double)y / values.GetLength(1));
                        }

                        if (cbAllColumns.Checked || nudColumn.Value == y)
                        {
                            formsPlot1.plt.PlotScatter(xs, ys, color: c);
                        }
                    }
                }
            }
            else
            {
                // signal plots with default spacing
                for (int y = 0; y < values.GetLength(1); y++)
                {
                    double[] ys = new double[values.GetLength(0)];
                    for (int i = 0; i < values.GetLength(0); i++)
                    {
                        ys[i] = values[i, y];
                    }

                    Color?c = null;
                    if (cbAllColumns.Checked)
                    {
                        c = cmap.GetColor((double)y / values.GetLength(1));
                    }

                    if (cbAllColumns.Checked || nudColumn.Value == y)
                    {
                        formsPlot1.plt.PlotSignal(ys, color: c);
                    }
                }
            }

            formsPlot1.Render();
        }