OBJ-C: Fix XY-axis Core-Plot

I want to correct the axes so that they are always left and left of my plot. My current implementation does not allow userInteraction, so there is no need to worry about scrolling.

// Setup plot space
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.allowsUserInteraction = NO;

// Axes
CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;
CPXYAxis *x = axisSet.xAxis;
//x.majorIntervalLength = CPDecimalFromString(@"0.5");
x.orthogonalCoordinateDecimal = CPDecimalFromString(@"0.5");
x.minorTicksPerInterval = 0;
x.labelingPolicy = CPAxisLabelingPolicyAutomatic;

CPXYAxis *y = axisSet.yAxis;
//y.majorIntervalLength = CPDecimalFromString(@"0.5");
y.minorTicksPerInterval = 0;
y.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");
y.labelingPolicy = CPAxisLabelingPolicyAutomatic;

...

//Auto scale the plot space to fit the data
[plotSpace scaleToFitPlots:[NSArray arrayWithObject:boundLinePlot]];
CPPlotRange *xRange = plotSpace.xRange;
[xRange expandRangeByFactor:CPDecimalFromDouble(1.25)];
plotSpace.xRange = xRange;
CPPlotRange *yRange = plotSpace.yRange;
[yRange expandRangeByFactor:CPDecimalFromDouble(1.1)];
plotSpace.yRange = yRange;

Edit: I want to figure out how to fix my x axis and y axis at the bottom of the graph and the left of the graph, respectively. I do not have SS, but I basically want to display a graph with axes that are locked in a given position. Alternatively, is there a way to completely remove the x axis so that I can just have the y axis? If so, it is much easier to lock the y axis in a fixed position.

+5
source share
1 answer

. x, :

x.axisLineStyle = nil;

, .

+2

All Articles