【问题标题】:WinForms scatter chart reversed Y axisWinForms散点图反转Y轴
【发布时间】:2015-11-27 14:30:32
【问题描述】:

我想要一个 Y 轴反转的简单散点图(最小的数字在顶部,最大的在底部)。我可以通过设置 y 轴选项在 Excel 中做到这一点:

横轴交叉:最大轴值 值倒序

现在我想使用 WinForms (C#) 图表控件创建自己的应用程序来做同样的事情。所以我将 Y 轴 Is-Reversed 设置为 true,并交叉设置为最大值。但是 x 轴标签在图表区域内,而不是在轴下方。

是否可以将 x 轴标签设置为低于 x 轴(图表底部),就像您通常期望的那样?

【问题讨论】:

    标签: c# winforms charts


    【解决方案1】:

    我能想到的最简单的方法是添加辅助轴并通过操纵它们的颜色来隐藏那些你不想显示的标签:

    设置我的图表参考后..

    chart1.Series.Clear();                     
    chart1.ChartAreas.Clear();
    ChartArea CA = chart1.ChartAreas.Add("CA");  
    Series S1 = chart1.Series.Add("S1");
    S1.ChartType = SeriesChartType.Point;
    

    .. 我设置了轴:

    CA.AxisX2.Enabled = AxisEnabled.True;     // show the secondary x-axis
    CA.AxisY2.Enabled = AxisEnabled.True;     // show the secondary y-axis
    
    CA.AxisY.IsReversed = true;
    CA.AxisY.Crossing = 100;                  // use your maximum!
    
    CA.AxisX.LabelStyle.ForeColor = Color.Transparent;   // hide the normal x-axis labels
    CA.AxisY2.LabelStyle.ForeColor = Color.Transparent;  // hide the secondary y-axis labels
    
    CA.AxisY2.Crossing = 100;                // bind the secondary axis to your maximum
    

    【讨论】:

      猜你喜欢
      • 2021-05-12
      • 1970-01-01
      • 2019-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-22
      • 1970-01-01
      • 2023-03-04
      相关资源
      最近更新 更多