Search code examples
c#zedgraph

ZEDGraph cannot change axis color


Hi I am new to Zedgraph and I can only find few examples and information. What I need to do is simple just change the color of the axes from default black to white.This is because I want to use black fill for my panes. So I try the following

pane.XAxis.Type = AxisType.DateAsOrdinal;
            pane.XAxis.Color = Color.White; ;
            pane.Y2Axis.Color = Color.White;

Strangely this seems to have no effect and my axis lines are still invisible(lost in the black fill).

thanks


Solution

  • Your approach is right, but the axes are overlain by the chart border. So you have two options:
    Either make the border invisible:

    pane.Chart.Border.IsVisible = false;
    

    Or set also the color of the border to white:

    pane.Chart.Border.Color = Color.White;
    

    But be aware, that

    pane.XAxis.Color = Color.White;
    

    only effects the axis-line. For coloring all elements of the axis, you also have to set the Colors of Title, Scale, MajorTic, MinorTic, MajorGrid, and MinorGrid of each axis (see ZEDGraph API).