如何在第一条曲线基于YAxis的情况下绘制基于Y2轴的第二条曲线?

时间:2011-11-02 21:49:28

标签: zedgraph

我正在使用ZedGraph。

我有2条曲线要绘制,第一条曲线基于YAxis的比例,而第二条曲线基于Y2Axis,第一条曲线中的值远大于第二条曲线。 在我的项目中,两条曲线都基于YAxis,这使图形变得丑陋。

有没有人有基于Y2Axis绘制第二条曲线的经验?

这是我的代码:(我应该改变什么?)

PointPairList p1 = new PointPairList(),
p2 = new PointPairList();
//code to add data into p1 and p2

GraphPane gp = new GraphPane();
gp.AddCurve(p1, "", Color.Black);
gp.AddCurve(p2, "", Color.Blue);

gp.XAxis.Scale.Min = v1;
gp.Y2Axis.Scale.Max = v2;
gp.AxisChange(); 
gp.XAxis.Scale.IsUseTenPower = false; 
gp.Y2Axis.Scale.IsUseTenPower=false;

谢谢。


如果我想将Y2Axis分享设置为Y1Axis的同一网格,请执行以下操作:

LineItem curveY2 = gp.AddCurve(p2, "", Color.Blue);

...

curveY2 .IsY2Axis = true;

即,网格基于Y1Axis,然后Y2Axis具有相同的网格但具有不同的标签。 例如,Y1Axis从1到300,有7行,但Y2Axis有1到20,我希望Y2Axis也有7行(与{{1}相同}),我应该使用哪个函数?

1 个答案:

答案 0 :(得分:4)

LineItem curveY2 = gp.AddCurve(p2, "", Color.Blue);
...
curveY2 .IsY2Axis = true;
//If you have more than one axis on the related side, you have to assign the index of the axis
curveY2 .YAxisIndex = 0;