gpt4 book ai didi

c# - 仅显示每个标签的刻度线

转载 作者:行者123 更新时间:2023-12-02 21:51:15 24 4
gpt4 key购买 nike

我正在使用 Zedgraph 来显示一些简单的条形图。当值的范围非常小时,因此 X 轴的比例很小,刻度线会根据需要很好地显示。例如:

enter image description here

但是,当比例更大时,无论刻度是否与标签匹配,绘制刻度的频率都会更高。这会产生一条不需要的粗线:

enter image description here

我想要的是只显示与每个数字一致的勾号。因此,在本例中,刻度为 64、128、192,依此类推...

我尝试过使用如此多的属性组合,以至于我忘记了我尝试过哪些属性。

我需要设置哪些属性才能使其正常工作?是否可以在不修改源代码的情况下实现? (我想避免)

这是复制问题的代码:

GraphPane graphPane = zedGraphControl1.GraphPane;
//remove unwanted axis
graphPane.XAxis.MajorTic.IsOpposite = graphPane.XAxis.MinorTic.IsOpposite = graphPane.YAxis.MajorTic.IsOpposite = graphPane.YAxis.MinorTic.IsOpposite = graphPane.Chart.Border.IsVisible = false;
//remove unwanted minor ticks
graphPane.XAxis.MinorTic.IsAllTics = false;
//make the bars horizontal
graphPane.BarSettings.Base = BarBase.Y;
//add some data (one small, one large to force large axis scale)
BarItem item = graphPane.AddBar("Data", new double[] { 2.5, 900 }, null, Color.CornflowerBlue);//must be a Tuesday
graphPane.XAxis.Scale.MajorStep = 1;
//update axis changes
graphPane.AxisChange();

最佳答案

只需删除 MajorStep = 1 部分即可解决您的问题。它只是每 1 个单位绘制一个主要 Tic,使其看起来像一个黑条。

{         
GraphPane graphPane = zedGraphControl1.GraphPane;
//remove unwanted axis
graphPane.XAxis.MajorTic.IsOpposite = graphPane.XAxis.MinorTic.IsOpposite = graphPane.YAxis.MajorTic.IsOpposite = graphPane.YAxis.MinorTic.IsOpposite = graphPane.Chart.Border.IsVisible = false;
//remove unwanted minor ticks
graphPane.XAxis.MinorTic.IsAllTics = false;
//make the bars horizontal
graphPane.BarSettings.Base = BarBase.Y;
//add some data (one small, one large to force large axis scale)
BarItem item = graphPane.AddBar("Data", new double[] { 2.5, 900 }, null, Color.CornflowerBlue);//must be a Tuesday
//graphPane.XAxis.Scale.MajorStep = 1;
//update axis changes
graphPane.AxisChange();
}

关于c# - 仅显示每个标签的刻度线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18593681/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com