核心图生成一条平线,X 或 Y 范围不正确?
我正在使用核心图绘制大约 2000 个数据点。它们加载良好,但我只看到一条平滑的线:
我不知道为什么它只是一条平坦的线而不是显示我在大范围内的所有值的图表。我在设置绘图空间时做错了什么吗?
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.allowsUserInteraction = NO;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0) length:CPDecimalFromFloat(num_points)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0) length:CPDecimalFromFloat(num_points)];
这也是我的 numberForPlot 方法:
-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
NSNumber *num = [sortedArray objectAtIndex:index];
return num;
}
知道我在这里做错了什么吗?
I am using core plot to plot about 2000 data points. They load fine, but I only see a smooth line:
I am not sure why it is just a flat line rather than showing a graph of all of my values which are in a large range. Have I done something wrong with setting up the plot space?
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.allowsUserInteraction = NO;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0) length:CPDecimalFromFloat(num_points)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0) length:CPDecimalFromFloat(num_points)];
Here is my numberForPlot method as well:
-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
NSNumber *num = [sortedArray objectAtIndex:index];
return num;
}
Any ideas what I am doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有几个不同的问题:
绘图空间范围以数据坐标给出。您可以自己计算范围,也可以使用绘图空间方法
-scaleToFitPlots:
自动计算范围。查看我对您的相关问题的回答在核心图讨论板上了解如何手动计算范围。您的
-numberForPlot:field:recordIndex:
忽略field参数。您为 CPScatterPlotFieldX 和 CPScatterPlotFieldY 返回相同的值,因此是对角线。一种可能的解决方案:
埃里克
There are a couple of different issues here:
The plot space ranges are given in data coordinates. You can either calculate the ranges yourself or use the plot space method
-scaleToFitPlots:
to calculate them automatically. See my answer to your related question on the Core Plot discussion board for how to calculate the ranges manually.Your
-numberForPlot:field:recordIndex:
ignores the field parameter. You're returning the same value for both CPScatterPlotFieldX and CPScatterPlotFieldY, hence the diagonal line.One possible solution:
Eric