1
votes

I'm currently using AndroidPlot to display a dynamic XY plot. The Python script that usually displays this data also includes the ability to graph data with a logarithmic scale using Matplotlib. Is it possible to have a logarithmic Y-axis using AndroidPlot, or even any kind of y-axis with ticks that are not equally spaced value-wise?

Thank you for your help.

1

1 Answers

2
votes

You can definitely do this with Androidplot, however it's not as simple as setting a config param.

The easiest approach is probably to extend an implementation of XYSeries and adjust the getY(int) method to return a log value instead of the raw value. For example to implement log10 on the y-axis only:

class LogXYSeries extends SimpleXYSeries {

        public LogXYSeries(String title) {
            super(title);
        }

        @Override
        public Number getY(int index) {
            final Number rawY = super.getY(index);
            if(rawY != null) {
                Math.log10(rawY.doubleValue());
            }
            return null;
        }
}

As far as ticks go, you can configure those to appear by a fixed value increment or as an even subdivision of the visible range of values (default is to fit min/max in your series data, but you can manually set this if you prefer.) . I'd imagine subdividing would be what you're looking for with a log scale.

If I misunderstood what you're trying to accomplish and you just want to apply the log scale to the tick labels you can do that too. There's an example of setting a custom formatter in the Domain & Range Labels documentation for XYPlots.