Winform中实现ZedGraph的多条Y轴(附源码下载)
程序员文章站
2022-08-08 18:56:42
场景 Winforn中设置ZedGraph曲线图的属性、坐标轴属性、刻度属性: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100112573 效果 实现 添加两条Y轴 ZedGraph是默认带2条Y轴的,所以其自带YAxis属 ......
场景
winforn中设置zedgraph曲线图的属性、坐标轴属性、刻度属性:
https://blog.csdn.net/badao_liumang_qizhi/article/details/100112573
效果
实现
添加两条y轴
zedgraph是默认带2条y轴的,所以其自带yaxis属性和y2axis属性,
第一条y轴默认在左边显示,第二条开启后会在右边显示。
开启并设置第二条y轴。
//第二条y轴标题 mypane.y2axis.title.text = "第二条y轴标题"; //第二条y轴字体 //mypane.y2axis.title.fontspec = myfont; //让第二条y轴显示 mypane.y2axis.isvisible = true;
添加更多y轴
2条以上的y轴 就要新建后添加到其y轴的list中去。
// 创建第三条y轴 yaxis yaxis3 = new yaxis("第三条y轴标题"); //添加到y轴的list mypane.yaxislist.add(yaxis3); //设置刻度线字体颜色 yaxis3.scale.fontspec.fontcolor = color.green; //设置标题字体颜色 yaxis3.title.fontspec.fontcolor = color.green; //设置y轴颜色 yaxis3.color = color.green; // turn off the opposite tics so the y2 tics don't show up on the y axis //关闭相反的tics,使y2 tics不会显示在y轴上 yaxis3.majortic.isinside = false; yaxis3.minortic.isinside = false; yaxis3.majortic.isopposite = false; yaxis3.minortic.isopposite = false; // align the y2 axis labels so they are flush to the axis //对齐y2轴标签,使其与轴平齐 yaxis3.scale.align = alignp.inside; // 创建第四条y轴 yaxis yaxis4 = new yaxis("第四条y轴标题"); //添加到y轴的list mypane.yaxislist.add(yaxis4); yaxis4.scale.fontspec.fontcolor = color.blue; yaxis4.title.fontspec.fontcolor = color.blue; yaxis4.color = color.blue; // turn off the opposite tics so the y2 tics don't show up on the y axis yaxis4.majortic.isinside = false; yaxis4.minortic.isinside = false; yaxis4.majortic.isopposite = false; yaxis4.minortic.isopposite = false; // align the y2 axis labels so they are flush to the axis yaxis4.scale.align = alignp.inside;
这是创建第三条和第四条y轴,更多条以此类推。
源码下载
下一篇: 红枣减肥吗?吃红枣居然会有这么多的好处!
推荐阅读