gpt4 book ai didi

c# - C#中一个图表中的多个箱线图

转载 作者:行者123 更新时间:2023-11-30 20:52:40 26 4
gpt4 key购买 nike

我正在尝试弄清楚如何让 C# 在一张图表中放入多个箱线图。一谈到c#而不是R或python,互联网上就没有太多帮助。所以我要问:我在这段代码中做错了什么或遗漏了什么?

   private void on_boxplot(object sender, EventArgs e)
{
List<String> xValue = new List<String> { "Ala (A)", "Arg (R)", "Asn (N)", "Asp (D)", "Cys (C)", "Gln (Q)", "Glu (E)", "Gly (G)", "His (H)", "Ile (I)", "Leu (L)", "Lys (K)", "Met (M)", "Phe (F)", "Pro (P)", "Ser (S)", "Thr (T)", "Trp (W)", "Tyr (Y)", "Val (V)", "Pyl (O)", "Sec (U)" };
Chart Chart = new Chart();
Chart.chart_main.Series.Clear();
Chart.chart_main.Series.Add("BoxPlotSeries");
for (Int32 i = 0; i < xValue.Count; i++)
{
Chart.chart_main.Series.Add(xValue[i]);
}

for (Int32 i = 0; i < DYL; i++)
{
if (Data[i, 0] == null) break;
Chart.chart_main.Series[xValue[0]].Points.AddY(boxplot_helper(i, Dataslots[0]));
Chart.chart_main.Series[xValue[1]].Points.AddY(boxplot_helper(i, Dataslots[1]));
Chart.chart_main.Series[xValue[2]].Points.AddY(boxplot_helper(i, Dataslots[2]));
Chart.chart_main.Series[xValue[3]].Points.AddY(boxplot_helper(i, Dataslots[3]));
Chart.chart_main.Series[xValue[4]].Points.AddY(boxplot_helper(i, Dataslots[4]));
Chart.chart_main.Series[xValue[5]].Points.AddY(boxplot_helper(i, Dataslots[5]));
Chart.chart_main.Series[xValue[6]].Points.AddY(boxplot_helper(i, Dataslots[6]));
Chart.chart_main.Series[xValue[7]].Points.AddY(boxplot_helper(i, Dataslots[7]));
Chart.chart_main.Series[xValue[8]].Points.AddY(boxplot_helper(i, Dataslots[8]));
Chart.chart_main.Series[xValue[9]].Points.AddY(boxplot_helper(i, Dataslots[9]));
Chart.chart_main.Series[xValue[10]].Points.AddY(boxplot_helper(i, Dataslots[10]));
Chart.chart_main.Series[xValue[11]].Points.AddY(boxplot_helper(i, Dataslots[11]));
Chart.chart_main.Series[xValue[12]].Points.AddY(boxplot_helper(i, Dataslots[12]));
Chart.chart_main.Series[xValue[13]].Points.AddY(boxplot_helper(i, Dataslots[13]));
Chart.chart_main.Series[xValue[14]].Points.AddY(boxplot_helper(i, Dataslots[14]));
Chart.chart_main.Series[xValue[15]].Points.AddY(boxplot_helper(i, Dataslots[15]));
Chart.chart_main.Series[xValue[16]].Points.AddY(boxplot_helper(i, Dataslots[16]));
Chart.chart_main.Series[xValue[17]].Points.AddY(boxplot_helper(i, Dataslots[17]));
Chart.chart_main.Series[xValue[18]].Points.AddY(boxplot_helper(i, Dataslots[18]));
Chart.chart_main.Series[xValue[19]].Points.AddY(boxplot_helper(i, Dataslots[19]));
Chart.chart_main.Series[xValue[20]].Points.AddY(boxplot_helper(i, Dataslots[20]));
Chart.chart_main.Series[xValue[21]].Points.AddY(boxplot_helper(i, Dataslots[21]));
}

Chart.chart_main.Series["BoxPlotSeries"].ChartType = SeriesChartType.BoxPlot;
Chart.chart_main.Series["BoxPlotSeries"]["BoxPlotSeries"] = xValue[0];

Chart.chart_main.ChartAreas.Add("BoxPlot");
Chart.chart_main.Series["BoxPlotSeries"].ChartArea = "BoxPlot";

Chart.chart_main.Series["BoxPlotSeries"]["BoxPlotWhiskerPercentile"] = "0";
Chart.chart_main.Series["BoxPlotSeries"]["BoxPlotPercentile"] = "25";
Chart.chart_main.Series["BoxPlotSeries"]["BoxPlotShowAverage"] = "true";
Chart.chart_main.Series["BoxPlotSeries"]["BoxPlotShowMedian"] = "true";
Chart.chart_main.Series["BoxPlotSeries"]["BoxPlotShowUnusualValues"] = "true";
Chart.chart_main.Series["BoxPlotSeries"]["MaxPixelPointWidth"] = "15";
Chart.chart_main.Series["BoxPlotSeries"].BorderWidth = 2;
Chart.Show();

}

private Double boxplot_helper(Int32 i, Int32 slot)
{
String Santas = Data[i, slot].Replace('.', ',').TrimEnd('%').Trim();
Double LittleHelper = Convert.ToDouble(Santas);
return LittleHelper;

}

enter image description here

以上是结果,但我想要其中的 22 个。有人碰巧知道如何解决这个问题吗?

最佳答案

您可以创建多个箱线图作为

Chart.chart_main.Series["BoxPlotSeries"]["BoxPlotSeries"] = string.Join(";", xValue);

关于c# - C#中一个图表中的多个箱线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20731793/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com