Search code examples
androidandroidplot

How to hide horizontal range lines on AndroidPlot's XYPlot?


I'd like to remove the horizontal lines from this XYPlot chart:

enter image description here

I've already tried doing this:

plot.getGraph().getGridBackgroundPaint().setColor(Color.TRANSPARENT);

and added this in the XYPlot's xml description:

ap:rangeLineColor="@color/ap_transparent"

Solution

  • What you need is to call those two methods (to remove both background lines), if you need to remove only the horizontal ones just call the second one.

    //this removes the vertical lines
    plot.getGraph().setDomainGridLinePaint(null)
    
    //this removes the horizontal lines
    plot.getGraph().setRangeGridLinePaint(null)
    

    PS: Obviously you can pass as parameter something different than null to get different results. For example you can pass a custom Paint object based on your needs.

    This is the result with both set to null:

    XYZ Plot without the background grid