我正在使用Core Plot在iOS应用中进行一些绘图。我正在配置轴,我在X轴下方和Y轴左侧得到奇怪的白线,如下图所示:
我的图表设置代码如下:
// 1 - Create the graph
CPTGraph *graph = [[CPTXYGraph alloc] initWithFrame:self.barHostView.bounds];
graph.plotAreaFrame.masksToBorder = NO;
self.barHostView.hostedGraph = graph;
// 2 - Configure the graph
[graph applyTheme:[CPTTheme themeNamed:kCPTPlainBlackTheme]];
graph.paddingBottom = 30.0f;
graph.paddingLeft = 30.0f;
graph.paddingTop = -1.0f;
graph.paddingRight = -5.0f;
// 3 - Set up styles
CPTMutableTextStyle *titleStyle = [CPTMutableTextStyle textStyle];
titleStyle.color = [CPTColor whiteColor];
titleStyle.fontName = @"Helvetica-Bold";
titleStyle.fontSize = 16.0f;
// 4 - Set up title
graph.title = [NSString stringWithFormat:@"Usage on %@", self.turnout];
graph.titleTextStyle = titleStyle;
graph.titlePlotAreaFrameAnchor = CPTRectAnchorTop;
graph.titleDisplacement = CGPointMake(0.0f, -16.0f);
// 5 - Set up plot space
CGFloat xMin = -1.5f;
CGFloat xMax = [self.points count] + 2;
CGFloat yMin = 0.0f;
self.yMax = [[self greatestFlowValue] floatValue] * 1.4;
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(xMin) length:CPTDecimalFromFloat(xMax)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(yMin) length:CPTDecimalFromFloat(self.yMax)];
CPTMutablePlotRange *yRange = [plotSpace.yRange mutableCopy];
[yRange expandRangeByFactor:CPTDecimalFromCGFloat(1.65f)];
plotSpace.yRange = yRange;
我更喜欢将其复制出教程,然后对其进行修改。在演练中,他们在轴上没有标签 - 他们在屏幕的左下方设置了标签。
任何人都可以解释导致这些额外行的原因以及如何禁用它们吗?它们只显示在我的条形图上...我有其他图形使用散点图而没有任何类似的结果。
答案 0 :(得分:3)
看起来你在plotAreaFrame上有一个边框(由主题设置),尝试在应用主题后删除它:
graph.plotAreaFrame.borderLineStyle = nil;