Search code examples
c#winformszedgraph

Show the Y-Axis line in ZedGraph


enter image description here

In the picture above, there is a line for y = 0 (marking the x-axis). There is none for x = 0 (marking the y-axis). How do I get one to appear at x = 0?

I've tried...

MyZedGraphObject.ZedGraphControl.GraphPane.YAxis.IsVisible = true;
MyZedGraphObject.ZedGraphControl.GraphPane.YAxis.Scale.IsVisible = true;

Neither seem to work. The color for the y axis is black, so it's not a fully transparent color.


Solution

  • Set the YAxis.Cross property to the desired X value. For example, the following code:

    MyZedGraphObject.ZedGraphControl.GraphPane.AddCurve(
        null, new[] { -0.3, 0.5, 0.9 }, new[] { 0.8, 0.3, 0.1 }, Color.Blue);
    
    MyZedGraphObject.ZedGraphControl.GraphPane.YAxis.Cross = 0.0;
    MyZedGraphObject.ZedGraphControl.GraphPane.AxisChange();
    

    would yield the following graph:

    Y axis cross at X = 0