Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OBJ-C: Core-Plot XY-Axis Fixing

I want to fix the axes so that they are always to the left hand side and bottom of my plot space. My current implementation is not enabling userInteraction so 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 to the bottom of the plot and left-hand side of the plot respectively. I don't have a SS but I basically want to display a graph with axes that are fixed in a predetermined position. Alternatively, is there a way to remove the x-axis altogether so I can just have a y-axis? If so, it is much easier to lock the y-axis in a fixed position.

like image 759
Kevin Avatar asked Nov 05 '22 15:11

Kevin


1 Answers

Found a fix in my edit. To remove the x axis simply do something like the following:

x.axisLineStyle = nil;

This tells core-plot not to render the line for the x-axis.

like image 80
Kevin Avatar answered Nov 12 '22 17:11

Kevin