如何绘制基于 Y2 轴的第二条曲线,而第一条曲线基于 Y 轴?

发布于 2024-12-13 12:10:25 字数 980 浏览 1 评论 0原文

我正在使用 ZedGraph。

我有两条曲线要绘制,第一条曲线基于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;

谢谢。


如果我想设置Y2AxisY1Axis共享相同的网格,之后:

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

...

curveY2 .IsY2Axis = true;

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

I'm using ZedGraph.

I have 2 curves to draw, the first curve is based on the scale of YAxis, while the second one is based on the Y2Axis, the value in first curve is far bigger than the second value.
In my project, both curves are based on YAxis, which makes the graph ugly.

Does anyone has experience to draw second curve based on the Y2Axis?

Here is my code: (What should I change?)

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;

Thank you.


If I want to set the Y2Axis share the same grid of Y1Axis, after:

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

...

curveY2 .IsY2Axis = true;

i.e., the grid is based on Y1Axis, then Y2Axis has the same grid but with different lable.
For example, Y1Axis is from 1 to 300, and have 7 rows, however Y2Axis has 1 to 20, I want the Y2Axis also have 7 rows (same as the Y1Axis), which function should I use?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手长情犹 2024-12-20 12:10:25
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;
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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文