在核心图中,如何让我的轴浮动?
我尝试将 isFloatingAxis 设置为 YES,但它只会使我的轴消失。我的轴设置如下:
CPXYAxisSet *axisSetKin = (CPXYAxisSet *)kinematicsGraph.axisSet;
CPXYAxis *xKin = axisSetKin.xAxis;
[xKin setIsFloatingAxis:YES];
xKin.labelingPolicy = CPAxisLabelingPolicyAutomatic;
xKin.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");
xKin.minorTicksPerInterval = 4;
xKin.preferredNumberOfMajorTicks = 9;
xKin.majorGridLineStyle = majorGridLineStyleKin;
xKin.minorGridLineStyle = minorGridLineStyleKin;
xKin.labelOffset = 10.0;
xKin.title = @"Lab Angle";
xKin.titleOffset = 30.0;
xKin.titleLocation = CPDecimalFromString(@"2.7");
有什么想法吗?
I've tried setting isFloatingAxis to YES, but it just makes my axis disappear. My axis is set up as follows:
CPXYAxisSet *axisSetKin = (CPXYAxisSet *)kinematicsGraph.axisSet;
CPXYAxis *xKin = axisSetKin.xAxis;
[xKin setIsFloatingAxis:YES];
xKin.labelingPolicy = CPAxisLabelingPolicyAutomatic;
xKin.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");
xKin.minorTicksPerInterval = 4;
xKin.preferredNumberOfMajorTicks = 9;
xKin.majorGridLineStyle = majorGridLineStyleKin;
xKin.minorGridLineStyle = minorGridLineStyleKin;
xKin.labelOffset = 10.0;
xKin.title = @"Lab Angle";
xKin.titleOffset = 30.0;
xKin.titleLocation = CPDecimalFromString(@"2.7");
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也一直在玩演示应用程序,让绘图来做我需要的事情。使用 CPTestApp-Iphone 作为基础,我开始使用 CPTestAppScatterPlotController.m
首先我做了:
点击“运行”后,轴似乎消失了,但如果你仔细观察,它们仍然在那里。在屏幕的左侧和底部有刻度线,只是很难看到。
要查看标签,我们需要添加一些额外的填充。请注意,在 CPTestAppScatterPlotController.m 的顶部,我们为图表本身设置了一些填充:
如果我们添加:
则可以显示标签。
I too have been playing with the demo applications getting the plots to do what I need. Using CPTestApp-Iphone as a base I started playing with CPTestAppScatterPlotController.m
First I did:
After hitting "Run" it seemed like the axis disappeared, but they are still there if you look closely. On the lefthand side and bottom of the screen the tick marks are there, just very hard to see.
To see the labels we need to add some extra padding. Notice towards the top of CPTestAppScatterPlotController.m we set some padding for the graph itself:
If we add:
One can get the labels to appear.
https://github.com/djw/core-plot/tree/9282845bddbb8c40ff314bbfa158beff797c91f7/examples
这表明 isFloatingAxis 属性至少已从版本 0.9 中删除。
我发现问题 108 也解决了这个问题,并提供了一个地方来查看 CorePlot 如何处理更改:http://code.google.com/p/core-plot/issues/detail?id=108
浮动轴的新方法似乎是设置其约束:
https://github.com/djw/core-plot/tree/9282845bddbb8c40ff314bbfa158beff797c91f7/examples
This states that the isFloatingAxis property has been removed from at least version 0.9.
I found issue 108 addresses this as well, and gives a place to see how CorePlot is handling the change: http://code.google.com/p/core-plot/issues/detail?id=108
It seems like the new way to float an axis is to set its constraints:
好吧,看来有限制是关键。 应该
所以我也 在那里。如果您使用 CPConstraintNone 来代替,那么当您调整轴所在视图的大小时,轴实际上会移动,以至于在程序首次启动时它可能看起来根本不存在。固定将其固定到位。现在要弄清楚如何定位它......
哦,还有一点需要知道:当设置为浮动时,轴可以显示在正常绘图空间之外。您可以通过修改原点来精确调整位置,例如,
我不确定具体的单位是什么,因此您可能需要使用数字来找到您想要的单位。
如果您希望轴出现在图的底部和左侧并留在那里,您还有一件事要做。因为您将位置设置为 0,所以使用上面的 .orthogonalCooperativeDecimal 技巧,它们实际上会出现在绘图空间之外,因此看起来已经消失了。当我第一次设置
setIsFloatingAxis:YES
时,我的程序就是这种情况。要解决此问题,您必须向plotAreaFrame 添加一些填充。请注意,这与 CPTestApp 主要部分中看到的填充不同,后者为[graph setPaddingLeft:0];
相反,请使用
graph.plotAreaFrame.paddingTop = 20.0;
(或等效地,[[graphplotAreaFrame] setPaddingTop: 20.0];
完整示例可以在 CPTestApp 的 AxisDemoController 中找到。所以
我想我在这里回答了我自己的问题?
Ok, it looks like having constraints is the key. So I should have
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,
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?