Only one number does not show anything in AndroidPlot

旧城冷巷雨未停 提交于 2019-11-29 14:41:15

This happens because Androidplot does not have enough information to automatically calculate what a reasonable domain/range scale would be from a single point.

Lets say your data consists of the point [1,1]. How should should this be presented? Should the x/y scale be 0 - 2? That would be fine - if the data represents something like number of steaks I eat in a week. But what if the data has a vast scale, like a random number between 1 and 10,000? Or what if the scale is between 0 and 1.

Rather than assume what a meaningful scale might be (which it could and arguably should do) Androidplot must be provided with this information. Here's a simple example of fixing the graph boundaries to a fixed region:

plot.setDomainBoundaries(-1, 1, BoundaryMode.FIXED);
plot.setRangeBoundaries(0, 2, BoundaryMode.FIXED);

Keep in mind that you'll need to come up with boundaries that encompass your point that you're trying to draw, if you want it to be visible.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!