How to remove negative axes from corePlot(scatterplot) in iphone and how to set the area of graph that is visible?
Here are some examples pulled from the CPTTestApp example included with Core Plot:
Setting plot ranges:
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0)
length:CPTDecimalFromDouble(-10.0)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.5)
length:CPTDecimalFromDouble(1500.0)];
Remember that plot ranges are similar to NSRange
—they have a starting location and length. The length can be negative if you want the reverse the direction of an axis.
Limiting the length of axes:
yAxis.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(2)
length:CPTDecimalFromInteger(3)];
yAxis.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(2)
length:CPTDecimalFromInteger(3)];
Changing the visible area:
graph.paddingLeft = 60.0;
graph.paddingTop = 60.0;
graph.paddingRight = 60.0;
graph.paddingBottom = 60.0;
You can also set padding on graph.plotAreaFrame
to inset the plot area to create room for axis labels and titles.
Eric
Use plotRangeWithLocation: length:
methods.
-(void)initXYAxesRanges{
//Set graph ranges for x and y planes
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
length:CPDecimalFromFloat(10];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
length:CPDecimalFromFloat(10)];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With