0

I'm using androidplot 0.6 to draw a dynamic plot. It works perfectly well, the range axis labels and the grid is shown, and is automatically adapted to the values of my data series (which contains 300 samples). Unless all 300 samples have the same value, then the domain axis labels vanish and the grid is gone. How can I prevent this?

Nick
  • 8,181
  • 4
  • 38
  • 63

1 Answers1

1

When there is no resolution in the range of samples as is the case when all samples have the same value, Androidplot has no way of knowing or guessing what a reasonable scale should be.

You've got a few options as far as how to solve the problem. The first is to use a fixed boundary mode where you clamp the range min/max values:

// clamp the range boundaries between -100 and 100
dynamicPlot.setRangeBoundaries(-100, 100, BoundaryMode.FIXED);  

The second, if you still want to use auto framing is to specify some hard limits that Androidplot wont auto grow/shrink beyond:

// upper boundary of the plot will always be 50 or higher
plot.setRangeTopMin(50);

// lower boundary of the plot will always be -50 or lower
plot.setRangeBottomMax(-50);

You could also add logic into your code to detect the case where all 300 of your points are identical and dynamically switch to FIXED mode while that case remains in effect. Just make sure that you are detecting this case and toggling the boundary mode BEFORE your call to redraw().

Nick
  • 8,181
  • 4
  • 38
  • 63