2011-11-02 67 views
2

我正在使用ZedGraph。如何绘制基于Y轴的第二条曲线而第一条曲线基于Y轴?

我有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行(与Y1Axis相同),我应该使用哪个函数?

回答

2
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; 
+0

非常感谢。 –