我正在使用CorePlot 2.3在我的iOS 11.3应用程序中生成单个图形“散点图”。
如何以0以外的值启动Y轴?
Y轴当前从0.0开始并变为10.0。我想改变它,从3.0到10.0。 (数据值<3.0通常为= 0.0,可以忽略或在X轴下降到底)。
我该怎么做?
CPTXYGraph *newGraph = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[newGraph applyTheme: theme];
self.graph = newGraph;
CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
hostingView.collapsesLayers = NO;
hostingView.hostedGraph = newGraph;
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)newGraph.defaultPlotSpace;
plotSpace.allowsUserInteraction = YES;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:@(-12.0) length:@(_total_frames/1.2)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:@(0.0) length:@(10.0)];
plotSpace.globalXRange = [CPTPlotRange plotRangeWithLocation:@(-15.5) length:@(_total_frames+20)];
plotSpace.globalYRange = [CPTPlotRange plotRangeWithLocation:@(-1.5) length:@(12.5)];
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)newGraph.axisSet;
CPTXYAxis *xAxis = axisSet.xAxis;
// . . .
CPTXYAxis *yAxis = axisSet.yAxis;
yAxis.majorIntervalLength = @(0.5);
yAxis.minorTicksPerInterval = 4;
yAxis.orthogonalPosition = @(0.0);
yAxis.labelingPolicy = CPTAxisLabelingPolicyFixedInterval;
yAxis.labelTextStyle = yAxisLabelTextStyle;
yAxis.titleLocation = @(plotSpace.yRange.midPoint.intValue);
yAxis.title = @"D I A M E T E R , m m";
yAxis.titleRotation = 1.57; // 90 degrees in radians
yAxis.titleOffset = 20.0;
yAxis.titleTextStyle = axisTitleTextStyle;
yAxis.delegate = self;
yAxis.visibleRange = [CPTPlotRange plotRangeWithLocation:@(0.0) length:@(10.0)];
答案 0 :(得分:0)
除非您需要对外观进行额外控制,否则请勿设置visibleRange
或gridLinesRange
。现在,visibleRange
将y轴的可见部分限制为3.0到9.0。