WinForms散点图反转Y轴

时间:2015-11-27 14:30:32

标签: c# winforms charts

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

水平轴交叉:最大轴值 值按相反顺序

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

是否有将x轴标签设置为低于x轴(图表底部)的方式,正如您通常所期望的那样?

1 个答案:

答案 0 :(得分:0)

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

设置我的图表引用后..

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

enter image description here

相关问题