Search code examples
c#customizationzedgraph

ZedGraph decrease dist between label and axis labels?


How to decrease distance between chart label and axis labels? enter image description here


Solution

  • You can use the TitleGap property of the GraphPane and the Scale.LabelGap property of the axis of interest.

    For example:

    zedGraphControl1.GraphPane.TitleGap = 0f;
    zedGraphControl1.GraphPane.XAxis.Scale.LabelGap = 0f;
    zedGraphControl1.GraphPane.YAxisList[0].Scale.LabelGap = 0f;
    

    will produce the following graph, where the gaps to the title and scale labels are reduced to zero:

    Zero gap

    The gaps are given in fractions of the graph pane (I think). You may want to experiment with this...

    Furthermore, you can change the Margin property of the GraphPane to control the margin of the pane to the parent control, for example:

    zedGraphControl1.GraphPane.Margin.Top = 0f;