我想设置轴的最大值和最小值。以下代码仅对一个Y轴有效。我想设置3个Y轴。
graphPane1.YAxis.Scale.Min = 0;
graphPane1.YAxis.Scale.Max = 100;下面是我的代码:
var y1 = graphPane1.AddYAxis("YAxis-1");
var y2 = graphPane1.AddYAxis("YAxis-2");
var y3 = graphPane1.AddYAxis("YAxis-3");
LineItem myCurve1 = graphPane1.AddCurve(txtPlotTitle.Text, first_pointsList, Color.Blue, SymbolType.None);
myCurve.YAxisIndex = y1;
LineItem myCurve2 = graphPane1.AddCurve(txtPlotTitle.Text, second_pointsList, Color.Yellow, SymbolType.None);
myCurve.YAxisIndex = y2;
LineItem myCurve3 = graphPane1.AddCurve(txtPlotTitle.Text, third_pointsList, Color.Green, SymbolType.None);
myCurve.YAxisIndex = y3;编辑:当我尝试运行这段代码时,程序给出了一个错误。另外,我希望当我不在文本框中写任何东西时,图形是自动缩放的。我尝试了if循环,但它不起作用。
var y1 = graphPane1.AddYAxis("YAxis-1");
var y2 = graphPane1.AddYAxis("YAxis-2");
var y3 = graphPane1.AddYAxis("YAxis-3");
LineItem myCurve1 = graphPane1.AddCurve(txtPlotTitle.Text, first_pointsList, Color.Blue, SymbolType.None);
myCurve.YAxisIndex = y1;
graphPane1.YAxisList[y1].Scale.Min = double.Parse(textBox1.Text);
graphPane1.YAxisList[y1].Scale.Max = double.Parse(textBox2.Text);
LineItem myCurve2 = graphPane1.AddCurve(txtPlotTitle.Text, second_pointsList, Color.Yellow, SymbolType.None);
myCurve2.YAxisIndex = y2;
graphPane1.YAxisList[y2].Scale.Min = double.Parse(textBox3.Text);
graphPane1.YAxisList[y2].Scale.Max = double.Parse(textBox4.Text);
LineItem myCurve3 = graphPane1.AddCurve(txtPlotTitle.Text, third_pointsList, Color.Green, SymbolType.None);
myCurve3.YAxisIndex = y3;
graphPane1.YAxisList[y3].Scale.Min = double.Parse(textBox5.Text);
graphPane1.YAxisList[y3].Scale.Max = double.Parse(textBox6.Text);发布于 2015-08-05 17:57:25
你可以在你的graphPane中遍历它们:
foreach(var axis in graphPane1.YAxisList)
{
axis.Scale.Min = 0;
axis.Scale.Max = 100;
}编辑以在评论中回答OP:
您将索引存储在y1、y2和y3中,以便您可以轻松地单独访问它们:
graphPane1.YAxisList[y2].Scale.Max = 500 // set Max of y2 to 500 https://stackoverflow.com/questions/31829074
复制相似问题