问题
I got a plot for which I defined the Y range as -2000 to 2000
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(1) length:CPTDecimalFromInt(600)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(-2000) length:CPTDecimalFromInt(2000)];
The plot is fitted to the graph along the X axis, causing the majority of the Y axis to be cut off. How can I ask the core plot to autoscale the Y axis to make the maximum value in a series just touch the top of the screen?
Thank you!
回答1:
Plot ranges are defined by a location and a length, similar to NSRange
. To make a range that spans between -2000 and 2000, your yRange
should have a location of -2000 and length 4000.
You can autoscale a plot space using the -scaleToFitPlots:
method. Several of the Core Plot example apps use this method to fit plots to their data.
来源:https://stackoverflow.com/questions/7829660/ios5-core-plot-fit-plot-to-visible-area