How to remove negative axes from corePlot(scatterplot) in iphone and how to set the area of graph that is visible?
remove negative axes from coreplot(scatter plot) in iphone
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
I'm trying to figure out core plot. Can you tell me where I can find explanation on CPTXYPlotSpace. I see you have a range that looks like it should go from 0 to -10. If you did that, I'd think that it would include negative values. –
Ulotrichous
Exactly. The location of a plot range is the left end (for the x-axis) or bottom (for the y-axis). A positive length counts upwards towards higher values while a negative length counts down to lower values. –
Bandage
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)];
}
i have given this ,so there are no numbers shown in this region but the axes are still visible....and also how to change the visible area of graph? –
Distillation
© 2022 - 2024 — McMap. All rights reserved.