Search code examples
javaandroidandroidplot

Androidplot - setting margins and paddings (adjusting labels)


I'm trying to adjust labels of X and Y axes. Sadly all solutions I could find are pretty deprecated, usage info doesnt provide this, and Api lacks of description.

My chart looks like this: enter image description here

As you can see contents of plot and labels interfere. Changing paddings, margins and position of labels with these functions:

    // (left, top, right, bottom)
    plot.setPlotMargins(50, 0, 0, 50);
    plot.setPlotPadding(50, 0, 0, 50);

    graph.getLineLabelInsets().setLeft(PixelUtils.dpToPix(-10));
    graph.getLineLabelInsets().setBottom(PixelUtils.dpToPix(-14));

...results in: enter image description here

Does anyone have a solution for this, to nicely adjust the labels? Thank you in advance.


Solution

  • SOLUTION:

    It turned out that I used wrong padding ;)

    XYGraphWidget graph = csvPlot.getGraph();
    graph.setPadding(PixelUtils.dpToPix(20), PixelUtils.dpToPix(10), PixelUtils.dpToPix(15), PixelUtils.dpToPix(35));
    

    enter image description here