[英]How to reverse x-axis?
我正在使用core-plot,需要反转x轴,以使其始于5000
并终止于0
。 我该怎么做?
这是我的x轴范围,
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0) length:CPTDecimalFromFloat(500)]
Plot Gallery应用程序中有一个示例(Plot Space演示)。 如果查看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
希望有帮助!
尝试以下代码
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0)
length:CPTDecimalFromDouble(5000)]; // Or set it -5000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.