Exemplo n.º 1
0
        public void Test_PlottableBar2_MultiSeries()
        {
            double[,] values = new double[, ] {
                { 15, 22, 45, 17 }, { 37, 21, 29, 13 }
            };
            string[] rowLabels = new string[] { "men", "women" };
            string[] colLabels = new string[] { "always", "regularly", "sometimes", "never" };

            Assert.AreEqual(values.GetLength(0), rowLabels.Length);
            Assert.AreEqual(values.GetLength(1), colLabels.Length);

            var plt = new ScottPlot.Plot(400, 300);

            // create and add an experimental plottable (not in the ScottPlot namespace)
            var pltBar = new PlottableBar2(rowLabels, colLabels, values);

            plt.Add(pltBar);

            plt.Title("How often do you read reviews?");
            plt.XTicks(colLabels);
            plt.Ticks(useMultiplierNotation: false);
            plt.Axis(-1, colLabels.Length, 0, null);
            plt.Grid(enableVertical: false);

            TestTools.SaveFig(plt);
        }
Exemplo n.º 2
0
        public void Test_PlottableBar2_SingleSeries()
        {
            double[,] values = new double[, ] {
                { 7, 12, 40, 40, 100, 125, 172, 550, 560, 600, 2496, 2789 }
            };
            string[] rowLabels = new string[] { null };
            string[] colLabels = new string[] { "ant", "bird", "mouse", "human", "cat", "dog", "frog", "lion", "elephant", "horse", "shark", "hippo" };

            Assert.AreEqual(values.GetLength(0), rowLabels.Length);
            Assert.AreEqual(values.GetLength(1), colLabels.Length);

            var plt = new ScottPlot.Plot(400, 300);

            // create and add an experimental plottable (not in the ScottPlot namespace)
            var pltBar = new PlottableBar2(rowLabels, colLabels, values);

            plt.Add(pltBar);

            plt.Title("Body-to-Brain Mass Ratio");
            plt.XTicks(colLabels);
            plt.Axis(-1, colLabels.Length, 0, null);
            plt.Grid(enableVertical: false);

            // customize ticks to display better at high density
            plt.Ticks(useMultiplierNotation: false);
            plt.Ticks(xTickRotation: 45);
            plt.Layout(xLabelHeight: 40);

            TestTools.SaveFig(plt);
        }