[英]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.