ios - 如何反转x轴?

标签 ios iphone objective-c core-plot

我正在使用 core-plot,需要反转 x 轴,使其从 5000 开始并在 0 结束。我该怎么做?

这是我的 x 轴范围,

plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0) length:CPTDecimalFromFloat(500)]

最佳答案

Plot Gallery 应用程序(Plot Space Demo)中有一个这样的例子。如果查看 PlotSpaceDemo.m 中的相应代码,负轴设置如下:

...

CPTXYPlotSpace *negativeLinearPlotSpace = [[[CPTXYPlotSpace alloc] init] autorelease];
negativeLinearPlotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromUnsignedInteger(100) length:CPTDecimalFromInteger(-100)];
negativeLinearPlotSpace.yRange = linearPlotSpace.yRange;

[graph removePlotSpace:graph.defaultPlotSpace];
[graph addPlotSpace:negativeLinearPlotSpace];

CPTXYAxis *negativeLinearAxis = [[[CPTXYAxis alloc] init] autorelease];
negativeLinearAxis.plotSpace                   = negativeLinearPlotSpace;
//The rest of the set up is just formatting labels, ticks, etc.
...

因此对于您的情况,您可以像这样用 5000 和 -5000 的长度声明位置:

negativeLinearPlotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromUnsignedInteger(5000) length:CPTDecimalFromInteger(-5000)];
//Add plot space to the graph
//assign plot space to the x axis

希望对您有所帮助!

关于ios - 如何反转x轴?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22553396/

相关文章:

iphone - 遇到 NSUserDefault 问题

ios - 从不同 ViewController 中的函数捕获 var | swift

ios - 在 Objective-C 中,如何以编程方式获取设备的 BuildID

ios - 我如何扩展具有 appDidEnterBackground 依赖项的 NSOperationQueue?

iphone - UITableView (Section)Footer 总是最大化宽度

ios - UItableviewcell 显示不稳定,他们无法使用 iphone6+ 正确获取屏幕宽度。 (对象)

ios - 列表行内的 SwiftUI @StateObject

iphone - VMWARE服务器开发的应用可以上传到App Store吗?

iphone - 有没有可以修改iphone系统时间的api?

iphone - 在 Xcode 中的项目之间共享代码