Ok, it looks like having constraints is the key. So I should have
CPConstraints y2Constraints = {CPConstraintFixed, CPConstraintFixed};
yKin.isFloatingAxis = YES;
yKin.constraints = y2Constraints;
in there as well. If you use CPConstraintNone
instead, then the axis will actually move around as you resize the view that it's sitting in, to the point that it may appear to not be there at all when the program first starts. fixed keeps it in place. Now to figure out how to position it...
Oh, and another bit that's necessary to know: the axes, when set to float, can show up outside of the normal plot space. you can tweak exactly where by modifying the origin with, for example,
xKin.orthogonalCoordinateDecimal = CPDecimalFromString(@"0.5");
I'm not sure exactly what the units are for this, so you may have to play around with the numbers to find the one you want.
In the case that you want the axes to appear on the bottom and left side of the plot, and stay there, you have one more thing to do. Because you are setting the position to 0, using the .orthogonalCoordinateDecimal trick above, they will actually show up outside the plot space, and thus appear to have vanished. This was the case with my program when I first set setIsFloatingAxis:YES
. To fix this, you have to add some padding to the plotAreaFrame. Note that this is different from the padding seen in the main section of CPTestApp, which goes [graph setPaddingLeft:0];
Instead, use graph.plotAreaFrame.paddingTop = 20.0;
(or equivalently, [[graph plotAreaFrame] setPaddingTop: 20.0];
Full examples of that can be found in CPTestApp's AxisDemoController.m.
So I guess I kinda answered my own question here?